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\Pretty;
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 * Prints exercise statistics.
23 * @author Konstantin Kudryashov <ever.zet@gmail.com>
25 final class PrettyStatisticsPrinter 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();
55 $scenarioStats = $statistics->getSkippedScenarios();
56 $this->listPrinter->printScenariosList($printer, 'skipped_scenarios_title', TestResult::SKIPPED, $scenarioStats);
58 $scenarioStats = $statistics->getFailedScenarios();
59 $this->listPrinter->printScenariosList($printer, 'failed_scenarios_title', TestResult::FAILED, $scenarioStats);
61 $this->counterPrinter->printCounters($printer, 'scenarios_count', $statistics->getScenarioStatCounts());
62 $this->counterPrinter->printCounters($printer, 'steps_count', $statistics->getStepStatCounts());
64 if ($formatter->getParameter('timer')) {
65 $timer = $statistics->getTimer();
66 $memory = $statistics->getMemory();
68 $formatter->getOutputPrinter()->writeln(sprintf('%s (%s)', $timer, $memory));