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\Helper\ResultToStringConverter;
14 use Behat\Behat\Output\Node\Printer\StepPrinter;
15 use Behat\Behat\Tester\Result\StepResult;
16 use Behat\Gherkin\Node\ScenarioLikeInterface as Scenario;
17 use Behat\Gherkin\Node\StepNode;
18 use Behat\Testwork\Output\Formatter;
19 use Behat\Testwork\Tester\Result\TestResult;
22 * Behat progress step printer.
24 * @author Konstantin Kudryashov <ever.zet@gmail.com>
26 final class ProgressStepPrinter implements StepPrinter
29 * @var ResultToStringConverter
31 private $resultConverter;
35 private $stepsPrinted = 0;
38 * Initializes printer.
40 * @param ResultToStringConverter $resultConverter
42 public function __construct(ResultToStringConverter $resultConverter)
44 $this->resultConverter = $resultConverter;
50 public function printStep(Formatter $formatter, Scenario $scenario, StepNode $step, StepResult $result)
52 $printer = $formatter->getOutputPrinter();
53 $style = $this->resultConverter->convertResultToString($result);
55 switch ($result->getResultCode()) {
56 case TestResult::PASSED:
57 $printer->write("{+$style}.{-$style}");
59 case TestResult::SKIPPED:
60 $printer->write("{+$style}-{-$style}");
62 case TestResult::PENDING:
63 $printer->write("{+$style}P{-$style}");
65 case StepResult::UNDEFINED:
66 $printer->write("{+$style}U{-$style}");
68 case TestResult::FAILED:
69 $printer->write("{+$style}F{-$style}");
73 if (++$this->stepsPrinted % 70 == 0) {
74 $printer->writeln(' ' . $this->stepsPrinted);