flutter_gherkin icon indicating copy to clipboard operation
flutter_gherkin copied to clipboard

[Question] Is it possible to restart a test, when some step fails?

Open DiegoVega19 opened this issue 8 months ago • 0 comments

I have an application developed on Android, which I am running a few tests using the package, everything works correctly.

The problem is, when I am running all the tests, and one fails, it stays on the screen where the test failed, and it does not restart for the next test.

Is it possible to implement something similar or an option that allows doing something similar? I tried using hooks but it didn't work

Hooks code:

class ResetAppBetweenScenariosHook extends Hook {
 late FlutterRunProcessHandler? _flutterRunProcessHandler;

  @override
  Future<void> onAfterStep(World world, String step, StepResult stepResult) async {
    if (stepResult.result == StepExecutionResult.fail ||
        stepResult.result == StepExecutionResult.error ||
        stepResult.result == StepExecutionResult.timeout) {
          stdout.writeln('Restarting Flutter app');
          final myAppWorld = world as FlutterWorld;
          await myAppWorld.restartApp();
        }
    return super.onAfterStep(world, step, stepResult);
  }
  
 
}

DiegoVega19 avatar Jun 25 '24 21:06 DiegoVega19