Skip to content
This repository was archived by the owner on Mar 12, 2025. It is now read-only.

Commit ed4b12b

Browse files
authored
Merge pull request #56 from Codeception/7.1-phpunit-xml-testsuite-name
7.1 Add name attribute to per-file testsuite in Phpunit XML reports
2 parents 7c95e20 + 1ad26d9 commit ed4b12b

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
language: php
22

33
env:
4-
CODECEPTION_VERSION: 'dev-phpunit-xml-reports'
4+
CODECEPTION_VERSION: 'dev-phpunit-xml-reports-2'
55

66
php:
77
- 7.1

src/Log/PhpUnit.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ public function startTest(\PHPUnit\Framework\Test $test):void
4343

4444
$this->currentFile = $filename;
4545
$this->currentFileSuite = $this->document->createElement('testsuite');
46+
47+
if ($test instanceof Reported) {
48+
$reportFields = $test->getReportFields();
49+
$class = isset($reportFields['class']) ? $reportFields['class'] : $reportFields['name'];
50+
$this->currentFileSuite->setAttribute('name', $class);
51+
} else {
52+
$this->currentFileSuite->setAttribute('name', get_class($test));
53+
}
54+
4655
$this->currentFileSuite->setAttribute('file', $filename);
4756

4857
$this->testSuites[self::SUITE_LEVEL]->appendChild($this->currentFileSuite);

0 commit comments

Comments
 (0)