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 (stepResult.result == StepExecutionResult.fail ||
      stepResult.result == StepExecutionResult.error ||
      stepResult.result == StepExecutionResult.timeout) {
    try {
      final screenshotData = await takeScreenshot(world);
      world.attach(screenshotData, 'image/png', step);
    } catch (e, st) {
      world.attach('Failed to take screenshot\n$e\n$st', 'text/plain', step);
    }
  }
}