onAfterStep method

  1. @override
Future<void> onAfterStep(
  1. World world,
  2. String step,
  3. StepResult stepResult
)

Run after a step has executed

Implementation

@override
Future<void> onAfterStep(
    World world, String step, StepResult stepResult) async {
  if ([StepExecutionResult.fail, StepExecutionResult.error]
      .contains(stepResult.result)) {
    await takeScreenshot(withWidgetTreeRender: true, prefix: 'FAILED');
    currentWorld.reportFilesPath
        .where((file) => file.contains('FAILED'))
        .forEach((failedFile) {
      currentWorld.attach(failedFile, 'txt', step);
    });
  }
}