/** * Take screenshot after a failed step * * @param AfterStepTested $event */ public function checkAfterStep(AfterStepTested $event) { if ($event->getTestResult()->getResultCode() === TestResult::FAILED) { $stepFileName = $this->filenameGenerator->convertStepToFileName($event->getStep()); $this->screenshotTaker->takeScreenshot($stepFileName); } }
function it_does_not_take_a_screenshot_after_a_skipped_step(ScreenshotTaker $screenshotTaker, Environment $env, FeatureNode $feature, StepNode $step, StepResult $result, Teardown $tearDown) { $event = new AfterStepTested($env->getWrappedObject(), $feature->getWrappedObject(), $step->getWrappedObject(), $result->getWrappedObject(), $tearDown->getWrappedObject()); $result->getResultCode()->willReturn(TestResult::SKIPPED); $screenshotTaker->takeScreenshot()->shouldNotBeCalled(); $this->takeScreenshot($event); }
function it_generates_filename_from_step_name(ScreenshotTaker $screenshotTaker, StepFilenameGenerator $filenameGenerator, Environment $env, FeatureNode $feature, StepNode $step, StepResult $result, Teardown $tearDown) { $event = new AfterStepTested($env->getWrappedObject(), $feature->getWrappedObject(), $step->getWrappedObject(), $result->getWrappedObject(), $tearDown->getWrappedObject()); $result->getResultCode()->willReturn(TestResult::FAILED); $filenameGenerator->convertStepToFileName($step)->willReturn('test.jpg')->shouldBeCalled(); $screenshotTaker->takeScreenshot('test.jpg')->shouldBeCalled(); $this->checkAfterStep($event); }
/** * Take screenshot after each real (not skipped) step * * @param AfterStepTested $event */ public function takeScreenshot(AfterStepTested $event) { if ($this->shouldTakeScreenshot($event)) { $this->screenshotTaker->takeScreenshot(); } }