Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function printStep(Formatter $formatter, Scenario $scenario, StepNode $step, StepResult $result)
 {
     $printer = $formatter->getOutputPrinter();
     $style = $this->resultConverter->convertResultToString($result);
     switch ($result->getResultCode()) {
         case TestResult::PASSED:
             $printer->write("{+{$style}}.{-{$style}}");
             break;
         case TestResult::SKIPPED:
             $printer->write("{+{$style}}-{-{$style}}");
             break;
         case TestResult::PENDING:
             $printer->write("{+{$style}}P{-{$style}}");
             break;
         case StepResult::UNDEFINED:
             $printer->write("{+{$style}}U{-{$style}}");
             break;
         case TestResult::FAILED:
             $printer->write("{+{$style}}F{-{$style}}");
             break;
     }
     if (++$this->stepsPrinted % 70 == 0) {
         $printer->writeln(' ' . $this->stepsPrinted);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function listenEvent(Formatter $formatter, Event $event, $eventName)
 {
     if ($this->value !== $formatter->getParameter($this->name)) {
         return;
     }
     $this->descendant->listenEvent($formatter, $event, $eventName);
 }
Ejemplo n.º 3
0
 /**
  * Registers formatter.
  *
  * @param Formatter $formatter
  */
 public function registerFormatter(Formatter $formatter)
 {
     if (isset($this->formatters[$formatter->getName()])) {
         $this->disableFormatter($formatter->getName());
     }
     $this->formatters[$formatter->getName()] = $formatter;
 }
Ejemplo n.º 4
0
 /**
  * {@inheritdoc}
  */
 public function printExampleRow(Formatter $formatter, OutlineNode $outline, ExampleNode $example, array $events)
 {
     $rowNum = array_search($example, $outline->getExamples()) + 1;
     $wrapper = $this->getWrapperClosure($outline, $example, $events);
     $row = $outline->getExampleTable()->getRowAsStringWithWrappedValues($rowNum, $wrapper);
     $formatter->getOutputPrinter()->writeln(sprintf('%s%s', $this->indentText, $row));
     $this->printStepExceptionsAndStdOut($formatter->getOutputPrinter(), $events);
 }
Ejemplo n.º 5
0
 /**
  * {@inheritdoc}
  */
 public function printHeader(Formatter $formatter, FeatureNode $feature)
 {
     if ($feature instanceof TaggedNodeInterface) {
         $this->printTags($formatter->getOutputPrinter(), $feature->getTags());
     }
     $this->printTitle($formatter->getOutputPrinter(), $feature);
     $this->printDescription($formatter->getOutputPrinter(), $feature);
 }
Ejemplo n.º 6
0
 /**
  * Prints step path comment.
  *
  * @param Formatter  $formatter
  * @param Scenario   $scenario
  * @param StepNode   $step
  * @param StepResult $result
  * @param integer    $indentation
  */
 public function printStepPath(Formatter $formatter, Scenario $scenario, StepNode $step, StepResult $result, $indentation)
 {
     $printer = $formatter->getOutputPrinter();
     if (!$result instanceof DefinedStepResult || !$result->getStepDefinition() || !$formatter->getParameter('paths')) {
         $printer->writeln();
         return;
     }
     $textWidth = $this->widthCalculator->calculateStepWidth($step, $indentation);
     $scenarioWidth = $this->widthCalculator->calculateScenarioWidth($scenario, $indentation - 2, 2);
     $this->printDefinedStepPath($printer, $result, $scenarioWidth, $textWidth);
 }
Ejemplo n.º 7
0
 /**
  * {@inheritDoc}
  */
 public function printOpenTag(Formatter $formatter, FeatureNode $feature, ScenarioLikeInterface $scenario, TestResult $result)
 {
     $name = implode(' ', array_map(function ($l) {
         return trim($l);
     }, explode("\n", $scenario->getTitle())));
     if ($scenario instanceof ExampleNode) {
         $name = $this->buildExampleName();
     }
     /** @var JUnitOutputPrinter $outputPrinter */
     $outputPrinter = $formatter->getOutputPrinter();
     $outputPrinter->addTestcase(array('name' => $name, 'status' => $this->resultConverter->convertResultToString($result)));
 }
Ejemplo n.º 8
0
 /**
  * {@inheritDoc}
  */
 public function printHeader(Formatter $formatter, FeatureNode $feature)
 {
     $stats = $this->statistics->getScenarioStatCounts();
     if (0 === count($stats)) {
         $totalCount = 0;
     } else {
         $totalCount = array_sum($stats);
     }
     /** @var JUnitOutputPrinter $outputPrinter */
     $outputPrinter = $formatter->getOutputPrinter();
     $outputPrinter->addTestsuite(array('name' => $feature->getTitle(), 'tests' => $totalCount, 'skipped' => $stats[TestResult::SKIPPED], 'failures' => $stats[TestResult::FAILED], 'errors' => $stats[TestResult::PENDING] + $stats[StepResult::UNDEFINED]));
     $this->statistics->reset();
 }
Ejemplo n.º 9
0
 /**
  * {@inheritdoc}
  */
 public function printStatistics(Formatter $formatter, Statistics $statistics)
 {
     $printer = $formatter->getOutputPrinter();
     $scenarioStats = $statistics->getSkippedScenarios();
     $this->listPrinter->printScenariosList($printer, 'skipped_scenarios_title', TestResult::SKIPPED, $scenarioStats);
     $scenarioStats = $statistics->getFailedScenarios();
     $this->listPrinter->printScenariosList($printer, 'failed_scenarios_title', TestResult::FAILED, $scenarioStats);
     $this->counterPrinter->printCounters($printer, 'scenarios_count', $statistics->getScenarioStatCounts());
     $this->counterPrinter->printCounters($printer, 'steps_count', $statistics->getStepStatCounts());
     if ($formatter->getParameter('timer')) {
         $timer = $statistics->getTimer();
         $memory = $statistics->getMemory();
         $formatter->getOutputPrinter()->writeln(sprintf('%s (%s)', $timer, $memory));
     }
 }
Ejemplo n.º 10
0
 /**
  * {@inheritdoc}
  */
 public function printTeardown(Formatter $formatter, Teardown $teardown)
 {
     if (!$teardown instanceof HookedTeardown) {
         return;
     }
     foreach ($teardown->getHookCallResults() as $callResult) {
         $this->printTeardownHookCallResult($formatter->getOutputPrinter(), $callResult);
     }
 }
Ejemplo n.º 11
0
 /**
  * @param Formatter $formatter
  * @param CallResults $results
  * @param string $messageType
  */
 private function handleHookCalls(Formatter $formatter, CallResults $results, $messageType)
 {
     /** @var CallResult $hookCallResult */
     foreach ($results as $hookCallResult) {
         if ($hookCallResult->hasException()) {
             /** @var HookCall $call */
             $call = $hookCallResult->getCall();
             $scope = $call->getScope();
             /** @var JUnitOutputPrinter $outputPrinter */
             $outputPrinter = $formatter->getOutputPrinter();
             $message = '';
             if ($scope instanceof StepScope) {
                 $message .= $scope->getStep()->getKeyword() . ' ' . $scope->getStep()->getText() . ': ';
             }
             $message .= $this->exceptionPresenter->presentException($hookCallResult->getException());
             $attributes = array('message' => $message, 'type' => $messageType);
             $outputPrinter->addTestcaseChild('failure', $attributes);
         }
     }
 }
Ejemplo n.º 12
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;
     }
 }
 /**
  * {@inheritdoc}
  */
 public function printFooter(Formatter $formatter, TestResult $result)
 {
     $formatter->getOutputPrinter()->writeln();
 }
Ejemplo n.º 14
0
 /**
  * {@inheritdoc}
  */
 public function printHeader(Formatter $formatter, FeatureNode $feature, ExampleNode $example)
 {
     $this->printTitle($formatter->getOutputPrinter(), $example);
     $this->pathPrinter->printScenarioPath($formatter, $feature, $example, mb_strlen($this->indentText, 'utf8'));
 }
Ejemplo n.º 15
0
 /**
  * Prints step multiline arguments.
  *
  * @param Formatter           $formatter
  * @param ArgumentInterface[] $arguments
  */
 private function printArguments(Formatter $formatter, array $arguments)
 {
     $style = $this->resultConverter->convertResultCodeToString(TestResult::SKIPPED);
     foreach ($arguments as $argument) {
         $text = $this->getArgumentString($argument, !$formatter->getParameter('multiline'));
         $indentedText = implode("\n", array_map(array($this, 'subIndent'), explode("\n", $text)));
         $formatter->getOutputPrinter()->writeln(sprintf('{+%s}%s{-%s}', $style, $indentedText, $style));
     }
 }
Ejemplo n.º 16
0
 /**
  * {@inheritDoc}
  */
 public function printFooter(Formatter $formatter, Suite $suite)
 {
     $formatter->getOutputPrinter()->flush();
 }
 function its_printFooter_should_write_empty_line(Formatter $formatter, OutputPrinter $printer, TestResult $testResult)
 {
     $printer->writeln()->shouldBeCalled();
     $formatter->getOutputPrinter()->shouldBecalled()->willReturn($printer);
     $this->printFooter($formatter, $testResult);
 }