示例#1
0
 /**
  * Prints step using provided printer.
  *
  * @param Formatter  $formatter
  * @param Scenario   $scenario
  * @param StepNode   $step
  * @param StepResult $result
  */
 public function printStep(Formatter $formatter, Scenario $scenario, StepNode $step, StepResult $result)
 {
     /** @var JUnitOutputPrinter $outputPrinter */
     $outputPrinter = $formatter->getOutputPrinter();
     $message = $step->getKeyword() . ' ' . $step->getText();
     if ($result instanceof ExceptionResult && $result->hasException()) {
         $message .= ': ' . $this->exceptionPresenter->presentException($result->getException());
     }
     $attributes = array('message' => $message);
     switch ($result->getResultCode()) {
         case TestResult::FAILED:
             $outputPrinter->addTestcaseChild('failure', $attributes);
             break;
         case TestResult::PENDING:
             $attributes['type'] = 'pending';
             $outputPrinter->addTestcaseChild('error', $attributes);
             break;
         case StepResult::UNDEFINED:
             $attributes['type'] = 'undefined';
             $outputPrinter->addTestcaseChild('error', $attributes);
             break;
     }
 }
示例#2
0
 /**
  * Checks if result has produced exception.
  *
  * @return Boolean
  */
 private function resultHasException()
 {
     return $this->result instanceof ExceptionResult && $this->result->getException();
 }
示例#3
0
 /**
  * Gets exception from the step test results.
  *
  * @param StepResult $result
  *
  * @return null|Exception
  */
 private function getStepException(StepResult $result)
 {
     if ($result instanceof ExceptionResult) {
         return $result->getException();
     }
     return null;
 }