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\JUnit;
13 use Behat\Behat\Output\Node\Printer\FeaturePrinter;
14 use Behat\Behat\Output\Statistics\PhaseStatistics;
15 use Behat\Behat\Tester\Result\StepResult;
16 use Behat\Gherkin\Node\FeatureNode;
17 use Behat\Testwork\Output\Formatter;
18 use Behat\Testwork\Output\Printer\JUnitOutputPrinter;
19 use Behat\Testwork\Tester\Result\TestResult;
22 * Prints the <testsuite> element.
24 * @author Wouter J <wouter@wouterj.nl>
26 final class JUnitFeaturePrinter implements FeaturePrinter
29 * @var PhaseStatistics
33 public function __construct(PhaseStatistics $statistics)
35 $this->statistics = $statistics;
41 public function printHeader(Formatter $formatter, FeatureNode $feature)
43 $stats = $this->statistics->getScenarioStatCounts();
45 if (0 === count($stats)) {
48 $totalCount = array_sum($stats);
51 /** @var JUnitOutputPrinter $outputPrinter */
52 $outputPrinter = $formatter->getOutputPrinter();
54 $outputPrinter->addTestsuite(array(
55 'name' => $feature->getTitle(),
56 'tests' => $totalCount,
57 'skipped' => $stats[TestResult::SKIPPED],
58 'failures' => $stats[TestResult::FAILED],
59 'errors' => $stats[TestResult::PENDING] + $stats[StepResult::UNDEFINED],
61 $this->statistics->reset();
67 public function printFooter(Formatter $formatter, TestResult $result)