/** * Exits if scenario is a failure and if stopper is enabled. * * @param AfterScenarioTested $event */ public function exitOnFailure(AfterScenarioTested $event) { if (TestResult::FAILED !== $event->getTestResult()->getResultCode()) { return; } $this->eventDispatcher->dispatch(SuiteTested::AFTER, new AfterSuiteAborted($event->getEnvironment())); $this->eventDispatcher->dispatch(ExerciseCompleted::AFTER, new AfterExerciseAborted()); exit(1); }
/** * Exits if scenario is a failure and if stopper is enabled. * * @param AfterScenarioTested $event */ public function exitOnFailure(AfterScenarioTested $event) { if (!$this->resultInterpretation->isFailure($event->getTestResult())) { return; } $this->eventDispatcher->dispatch(SuiteTested::AFTER, new AfterSuiteAborted($event->getEnvironment())); $this->eventDispatcher->dispatch(ExerciseCompleted::AFTER, new AfterExerciseAborted()); exit(1); }
/** * @param AfterScenarioTested $event */ public function onAfterScenarioTested(AfterScenarioTested $event) { $scenarioPassed = $event->getTestResult()->isPassed(); if ($scenarioPassed) { $this->passedScenarios[] = $this->currentScenario; $this->currentFeature->addPassedScenario(); } else { $this->failedScenarios[] = $this->currentScenario; $this->currentFeature->addFailedScenario(); } $this->currentScenario->setLoopCount(1); $this->currentScenario->setPassed($event->getTestResult()->isPassed()); $this->currentFeature->addScenario($this->currentScenario); $print = $this->renderer->renderAfterScenario($this); $this->printer->writeln($print); }
/** * afterScenario * * @param mixed $event */ public function afterScenario(AfterScenarioTested $event) { $this->testcaseTimer->stop(); $code = $event->getTestResult()->getResultCode(); $testResultString = array(TestResult::PASSED => 'passed', TestResult::SKIPPED => 'skipped', TestResult::PENDING => 'pending', TestResult::FAILED => 'failed'); $this->testsuiteStats[$code]++; $this->currentTestcase->addAttribute('time', \round($this->testcaseTimer->getTime(), 3)); $this->currentTestcase->addAttribute('status', $testResultString[$code]); if ($this->lastStepFailure) { $failureNode = $this->currentTestcase->addChild('failure', $this->lastStepFailureException->getMessage()); $failureNode->addAttribute('message', $this->lastStepFailure); } }
/** * @param BehatEvent\AfterScenarioTested $event */ public function onAfterScenarioTested(BehatEvent\AfterScenarioTested $event) { $scenarioPassed = $event->getTestResult()->isPassed(); if ($scenarioPassed) { $this->passedScenarios[] = $this->currentScenario; $this->currentFeature->addPassedScenario(); } else { $this->failedScenarios[] = $this->currentScenario; $this->currentFeature->addFailedScenario(); } $this->currentScenario->setPassed($event->getTestResult()->isPassed()); $this->currentFeature->addScenario($this->currentScenario); }
/** * Records scenario if it is failed. * * @param AfterScenarioTested $event */ public function collectFailedScenario(AfterScenarioTested $event) { if (!$this->getFileName()) { return; } if ($event->getTestResult()->getResultCode() !== TestResult::FAILED) { return; } $feature = $event->getFeature(); $scenario = $event->getScenario(); $this->lines[] = $feature->getFile() . ':' . $scenario->getLine(); }
/** * @param AfterScenarioTested $event */ public function onAfterScenarioTested(AfterScenarioTested $event) { $scenarioPassed = $event->getTestResult()->isPassed(); if ($scenarioPassed) { $this->passedScenarios[] = $this->currentScenario; $this->currentFeature->addPassedScenario(); } else { $this->failedScenarios[] = $this->currentScenario; $this->currentFeature->addFailedScenario(); } $this->currentScenario->setLoopCount(1); $this->currentScenario->setPassed($event->getTestResult()->isPassed()); $this->currentFeature->addScenario($this->currentScenario); $print = $this->renderer->renderAfterScenario($this); /*Old logic*/ /*$this->printer->writeln($print);*/ /*New logic*/ //$featureName = $this->getCurrentFeature()->getName(); $featureName = $this->getCurrentFeature()->getFileName(); $this->printer->featureWriteln($print, $featureName); }
/** * @param AfterScenarioTested $event */ public function onAfterScenarioTested(AfterScenarioTested $event) { if (!$event->getTestResult()->isPassed()) { $this->printEvent("testFailed", array('name' => $event->getScenario()->getTitle())); } $this->printEvent("testFinished", array('name' => $event->getScenario()->getTitle())); }
public function afterScenario(AfterScenarioTested $event) { $this->scenarios[] = new Scenario($event, $this->steps); $this->updateStats("scenarios", $event->getTestResult()->getResultCode()); $this->steps = array(); }
/** * @param AfterScenarioTested $event */ public function onAfterScenarioTested(AfterScenarioTested $event) { $scenarioPassed = $event->getTestResult()->isPassed(); if ($scenarioPassed) { $this->passedScenarios[] = $this->currentScenario; $this->currentFeature->addPassedScenario(); } else { //set screenshot properties $this->currentScenario->setScreenshotProperties($this->printer->getOutputPath(), 'assets/screenshots/', $event->getFeature()->getTitle()); $this->failedScenarios[] = $this->currentScenario; $this->currentFeature->addFailedScenario(); } $this->currentScenario->setLoopCount(1); $this->currentScenario->setPassed($event->getTestResult()->isPassed()); $this->currentFeature->addScenario($this->currentScenario); $print = $this->renderer->renderAfterScenario($this); $this->printer->writeln($print); }