/** * 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); } }
public function pauseAfterStep(AfterStepTested $event) { if (in_array($event->getTestResult()->getResultCode(), array(TestResult::PENDING, TestResult::SKIPPED))) { return; } $this->pauser->pause($event->getStep()->getText()); }
public function getStepResult(AfterStepTested $event) { array_push($this->results_array, $event->getTestResult()->getResultCode()); if (preg_match("/I report case result \"([0-9]+)\"\$/", $event->getStep()->getText(), $output_array)) { $key = $output_array[1]; print "Scenario result for case id #" . $key . " ->" . $this->get_result_by_array() . "\n"; TestRailApiWrapper::log_testcase_result($key, $this->get_result_by_array(), "description"); // Clean results $this->results_array = []; } }
/** * afterStep callback * @param AfterStepTested $event object * @return null */ public function afterStep(AfterStepTested $event) { $this->testResults->addStepResult($this->currentFeature, $this->currentScenario, $event->getStep(), $event->getTestResult()); $this->testResults->updateScenarioStatus($this->currentFeature, $this->currentScenario, $event->getTestResult()); $this->testResults->updateFeatureStatus($this->currentFeature, $event->getTestResult()); }
/** * Gets step path from the AFTER test event and exception. * * @param AfterStepTested $event * @param null|Exception $exception * * @return string */ private function getStepPath(AfterStepTested $event, Exception $exception = null) { $path = sprintf('%s:%d', $this->currentFeaturePath, $event->getStep()->getLine()); if ($exception && $exception instanceof PendingException) { $path = $event->getTestResult()->getStepDefinition()->getPath(); } return $path; }
/** * @param AfterStepTested $event */ public function onAfterStepTested(AfterStepTested $event) { $result = $event->getTestResult(); //$this->dumpObj($event->getStep()->getArguments()); /** @var Step $step */ $step = new Step(); $step->setKeyword($event->getStep()->getKeyword()); $step->setText($event->getStep()->getText()); $step->setLine($event->getStep()->getLine()); $step->setArguments($event->getStep()->getArguments()); $step->setResult($result); $step->setResultCode($result->getResultCode()); //What is the result of this step ? if (is_a($result, 'Behat\\Behat\\Tester\\Result\\UndefinedStepResult')) { //pending step -> no definition to load $this->pendingSteps[] = $step; } else { if (is_a($result, 'Behat\\Behat\\Tester\\Result\\SkippedStepResult')) { //skipped step /** @var ExecutedStepResult $result */ $step->setDefinition($result->getStepDefinition()); $this->skippedSteps[] = $step; } else { //failed or passed if ($result instanceof ExecutedStepResult) { $step->setDefinition($result->getStepDefinition()); $exception = $result->getException(); if ($exception) { $step->setException($exception->getMessage()); $this->failedSteps[] = $step; } else { $step->setOutput($result->getCallResult()->getStdOut()); $this->passedSteps[] = $step; } } } } $this->currentScenario->addStep($step); $print = $this->renderer->renderAfterStep($this); $this->printer->writeln($print); }
/** * Registers undefined step. * * @param AfterStepTested $event */ public function registerUndefinedStep(AfterStepTested $event) { if (StepResult::UNDEFINED === $event->getTestResult()->getResultCode()) { $this->registry->registerUndefinedStep($event->getEnvironment(), $event->getStep()); } }
public function afterStep(AfterStepTested $event) { /** @var ExecutedStepResult $result */ $result = $event->getTestResult(); if ($result->getResultCode() === TestResult::FAILED) { $exception = $result->getException(); if ($exception) { $this->lastStepFailure = sprintf('%s:%d', $event->getFeature()->getFile(), $event->getStep()->getLine()); $this->lastStepFailureException = $exception; } } elseif ($result->getResultCode() === TestResult::PASSED) { $this->lastStepFailure = null; $this->lastStepFailureException = null; } }
/** * @param AfterStepTested $event */ public function onAfterStepTested(AfterStepTested $event) { $result = $event->getTestResult(); if ($result instanceof ExecutedStepResult) { $exception = $result->getException(); if ($exception) { $this->printEvent("testStdErr", array('name' => $exception->getFile(), "out" => $exception->getMessage())); } } $this->printEvent("testStdOut", array('name' => $event->getStep()->getText())); }
public function getStepResult(AfterStepTested $event) { array_push($this->results_array, $event->getTestResult()->getResultCode()); // save message on fail if ($event->getTestResult()->getResultCode() == 99) { FoxFeatureContext::$stepResultDetails[$event->getStep()->getLine()]['error message'] = $event->getTestResult()->getException()->getMessage(); } if (preg_match("/I report case result \"([0-9]+)\"\$/", $event->getStep()->getText(), $output_array)) { $key = $output_array[1]; print "Scenario result for case id #" . $key . " ->" . $this->get_result_by_array() . "\n"; TestRailApiWrapper::log_testcase_result($key, $this->get_result_by_array(), $this->buildComment()); // Clean results $this->results_array = []; FoxFeatureContext::$stepResultDetails = []; } }