コード例 #1
0
 /**
  * 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);
 }
コード例 #2
0
 /**
  * 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);
 }
コード例 #3
0
 /**
  * @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);
 }
コード例 #4
0
 /**
  * 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);
     }
 }
コード例 #5
0
 /**
  * @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);
 }
コード例 #6
0
ファイル: RerunController.php プロジェクト: aaa2000/Behat
 /**
  * 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();
 }
コード例 #7
0
 /**
  * @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);
 }
コード例 #8
0
 /**
  * @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()));
 }
コード例 #9
0
 public function afterScenario(AfterScenarioTested $event)
 {
     $this->scenarios[] = new Scenario($event, $this->steps);
     $this->updateStats("scenarios", $event->getTestResult()->getResultCode());
     $this->steps = array();
 }
コード例 #10
0
 /**
  * @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);
 }