4 * This file is part of the Behat.
5 * (c) Konstantin Kudryashov <ever.zet@gmail.com>
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
11 namespace Behat\Behat\Output\Node\Printer\Progress;
13 use Behat\Behat\Output\Node\Printer\CounterPrinter;
14 use Behat\Behat\Output\Node\Printer\ListPrinter;
15 use Behat\Behat\Output\Node\Printer\StatisticsPrinter;
16 use Behat\Behat\Output\Statistics\Statistics;
17 use Behat\Testwork\Output\Formatter;
18 use Behat\Testwork\Tester\Result\TestResult;
21 * Behat progress statistics printer.
23 * @author Konstantin Kudryashov <ever.zet@gmail.com>
25 final class ProgressStatisticsPrinter implements StatisticsPrinter
30 private $counterPrinter;
37 * Initializes printer.
39 * @param CounterPrinter $counterPrinter
40 * @param ListPrinter $listPrinter
42 public function __construct(CounterPrinter $counterPrinter, ListPrinter $listPrinter)
44 $this->counterPrinter = $counterPrinter;
45 $this->listPrinter = $listPrinter;
51 public function printStatistics(Formatter $formatter, Statistics $statistics)
53 $printer = $formatter->getOutputPrinter();
58 $hookStats = $statistics->getFailedHookStats();
59 $this->listPrinter->printFailedHooksList($printer, 'failed_hooks_title', $hookStats);
61 $stepStats = $statistics->getFailedSteps();
62 $this->listPrinter->printStepList($printer, 'failed_steps_title', TestResult::FAILED, $stepStats);
64 $stepStats = $statistics->getPendingSteps();
65 $this->listPrinter->printStepList($printer, 'pending_steps_title', TestResult::PENDING, $stepStats);
67 $this->counterPrinter->printCounters($printer, 'scenarios_count', $statistics->getScenarioStatCounts());
68 $this->counterPrinter->printCounters($printer, 'steps_count', $statistics->getStepStatCounts());
70 if ($formatter->getParameter('timer')) {
71 $timer = $statistics->getTimer();
72 $memory = $statistics->getMemory();
74 $formatter->getOutputPrinter()->writeln(sprintf('%s (%s)', $timer, $memory));