예제 #1
0
 /**
  * Prints statistics on after exercise event.
  *
  * @param Formatter $formatter
  * @param string    $eventName
  */
 private function printStatisticsOnAfterExerciseEvent(Formatter $formatter, $eventName)
 {
     if (ExerciseCompleted::AFTER !== $eventName) {
         return;
     }
     $this->statistics->stopTimer();
     $this->printer->printStatistics($formatter, $this->statistics);
 }
예제 #2
0
 /**
  * Captures hook call result.
  *
  * @param CallResult $hookCallResult
  */
 private function captureHookStat(CallResult $hookCallResult)
 {
     $callee = $hookCallResult->getCall()->getCallee();
     $hook = (string) $callee;
     $path = $callee->getPath();
     $stdOut = $hookCallResult->getStdOut();
     $error = $hookCallResult->getException() ? $this->exceptionPresenter->presentException($hookCallResult->getException()) : null;
     $stat = new HookStat($hook, $path, $error, $stdOut);
     $this->statistics->registerHookStat($stat);
 }
예제 #3
0
 /**
  * Captures scenario or example stats on their AFTER event.
  *
  * @param Event $event
  */
 private function captureScenarioOrExampleStatsOnAfterEvent(Event $event)
 {
     if (!$event instanceof AfterScenarioTested) {
         return;
     }
     $scenario = $event->getScenario();
     $title = $scenario->getTitle();
     $path = sprintf('%s:%d', $this->currentFeaturePath, $scenario->getLine());
     $resultCode = $event->getTestResult()->getResultCode();
     $stat = new ScenarioStat($title, $path, $resultCode);
     $this->statistics->registerScenarioStat($stat);
 }
예제 #4
0
 /**
  * Captures step stats on step AFTER event.
  *
  * @param Event $event
  */
 private function captureStepStatsOnAfterEvent(Event $event)
 {
     if (!$event instanceof AfterStepTested) {
         return;
     }
     $result = $event->getTestResult();
     $step = $event->getStep();
     $text = sprintf('%s %s', $step->getKeyword(), $step->getText());
     $exception = $this->getStepException($result);
     $path = $this->getStepPath($event, $exception);
     $error = $exception ? $this->exceptionPresenter->presentException($exception) : null;
     $stdOut = $result instanceof ExecutedStepResult ? $result->getCallResult()->getStdOut() : null;
     $resultCode = $result->getResultCode();
     $stat = new StepStatV2($this->scenarioTitle, $this->scenarioPath, $text, $path, $resultCode, $error, $stdOut);
     $this->statistics->registerStepStat($stat);
 }
예제 #5
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));
     }
 }