Skip to content

Commit

Permalink
add name property to testsuites element in JunitXmlLogger
Browse files Browse the repository at this point in the history
This commit adds and sets the name property on the testsuites element
of the generated JUnit report to 'PHPUnit tests'. This is in line with
behaviour in Jest and Vitest where the tools set that property to
their respective names.
  • Loading branch information
joseph-sentry authored and sebastianbergmann committed Aug 28, 2024
1 parent 3167dd3 commit 1ec05a4
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/Logging/JUnit/JunitXmlLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ private function createDocument(): void
$this->document->formatOutput = true;

$this->root = $this->document->createElement('testsuites');
$this->root->setAttribute('name', 'PHPUnit tests');
$this->document->appendChild($this->root);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/end-to-end/cli/no-log-no-cc.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ print file_get_contents($logfile);
unlink($logfile);
--EXPECTF--
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuites name="PHPUnit tests">
<testsuite name="PHPUnit\TestFixture\NoLogNoCcTest" file="%sNoLogNoCcTest.php" tests="1" assertions="1" errors="0" failures="0" skipped="0" time="%f">
<testcase name="testSuccess" file="%sNoLogNoCcTest.php" line="19" class="PHPUnit\TestFixture\NoLogNoCcTest" classname="PHPUnit.TestFixture.NoLogNoCcTest" assertions="1" time="%f"/>
</testsuite>
Expand Down
2 changes: 1 addition & 1 deletion tests/end-to-end/data-provider/log-junit-isolation.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ print file_get_contents($logfile);
unlink($logfile);
--EXPECTF--
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuites name="PHPUnit tests">
<testsuite name="PHPUnit\TestFixture\DataProviderTest" file="%sDataProviderTest.php" tests="4" assertions="4" errors="0" failures="1" skipped="0" time="%f">
<testsuite name="PHPUnit\TestFixture\DataProviderTest::testAdd" tests="4" assertions="4" errors="0" failures="1" skipped="0" time="%f">
<testcase name="testAdd with data set #0" file="%sDataProviderTest.php" line="%d" class="PHPUnit\TestFixture\DataProviderTest" classname="PHPUnit.TestFixture.DataProviderTest" assertions="1" time="%f"/>
Expand Down
2 changes: 1 addition & 1 deletion tests/end-to-end/data-provider/log-junit.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ print file_get_contents($logfile);
unlink($logfile);
--EXPECTF--
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuites name="PHPUnit tests">
<testsuite name="CLI Arguments" tests="10" assertions="10" errors="0" failures="3" skipped="0" time="%s">
<testsuite name="PHPUnit\TestFixture\DataProviderTest" file="%sDataProviderTest.php" tests="4" assertions="4" errors="0" failures="1" skipped="0" time="%s">
<testsuite name="PHPUnit\TestFixture\DataProviderTest::testAdd" tests="4" assertions="4" errors="0" failures="1" skipped="0" time="%s">
Expand Down
2 changes: 1 addition & 1 deletion tests/end-to-end/logging/log-junit-to-file.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ print file_get_contents($logfile);
unlink($logfile);
--EXPECTF--
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuites name="PHPUnit tests">
<testsuite name="PHPUnit\TestFixture\Basic\StatusTest" file="%sStatusTest.php" tests="13" assertions="4" errors="2" failures="2" skipped="5" time="%f">
<testcase name="testSuccess" file="%sStatusTest.php" line="%d" class="PHPUnit\TestFixture\Basic\StatusTest" classname="PHPUnit.TestFixture.Basic.StatusTest" assertions="1" time="%f"/>
<testcase name="testFailure" file="%sStatusTest.php" line="%d" class="PHPUnit\TestFixture\Basic\StatusTest" classname="PHPUnit.TestFixture.Basic.StatusTest" assertions="1" time="%f">
Expand Down
2 changes: 1 addition & 1 deletion tests/end-to-end/logging/log-junit-to-stdout.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require_once __DIR__ . '/../../bootstrap.php';
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
--EXPECTF--
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuites name="PHPUnit tests">
<testsuite name="PHPUnit\TestFixture\Basic\StatusTest" file="%sStatusTest.php" tests="13" assertions="4" errors="2" failures="2" skipped="5" time="%f">
<testcase name="testSuccess" file="%sStatusTest.php" line="%d" class="PHPUnit\TestFixture\Basic\StatusTest" classname="PHPUnit.TestFixture.Basic.StatusTest" assertions="1" time="%f"/>
<testcase name="testFailure" file="%sStatusTest.php" line="%d" class="PHPUnit\TestFixture\Basic\StatusTest" classname="PHPUnit.TestFixture.Basic.StatusTest" assertions="1" time="%f">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ TypeError: Cannot assign DateTime to property PHPUnit\TestFixture\TypeErrorTest:
ERRORS!
Tests: 1, Assertions: 0, Errors: 1.
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuites name="PHPUnit tests">
<testsuite name="PHPUnit\TestFixture\TypeErrorTest" file="%sTypeErrorTest.php" tests="1" assertions="0" errors="1" failures="0" skipped="0" time="%f">
<testcase name="testMe" file="%sTypeErrorTest.php" line="%d" class="PHPUnit\TestFixture\TypeErrorTest" classname="PHPUnit.TestFixture.TypeErrorTest" assertions="0" time="%f">
<error type="TypeError">PHPUnit\TestFixture\TypeErrorTest::testMe
Expand Down
2 changes: 1 addition & 1 deletion tests/end-to-end/regression/5258.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Time: %s, Memory: %s MB
OK, but some tests were skipped!
Tests: 2, Assertions: 1, Skipped: 1.
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuites name="PHPUnit tests">
<testsuite name="PHPUnit\TestFixture\Issue5258\Issue5258Test" file="%sIssue5258Test.php" tests="2" assertions="1" errors="0" failures="0" skipped="1" time="%f">
<testcase name="testOne" file="%sIssue5258Test.php" line="%d" class="PHPUnit\TestFixture\Issue5258\Issue5258Test" classname="PHPUnit.TestFixture.Issue5258.Issue5258Test" assertions="1" time="%f"/>
<testcase name="testTwo" file="%sIssue5258Test.php" line="%d" class="PHPUnit\TestFixture\Issue5258\Issue5258Test" classname="PHPUnit.TestFixture.Issue5258.Issue5258Test" assertions="0" time="0.000000">
Expand Down
2 changes: 1 addition & 1 deletion tests/end-to-end/regression/5561.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require_once __DIR__ . '/../../bootstrap.php';
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
--EXPECTF--
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuites name="PHPUnit tests">
<testsuite name="PHPUnit\TestFixture\Issue5561\Issue5561Test" file="%sIssue5561Test.php" tests="1" assertions="0" errors="0" failures="1" skipped="0" time="%s">
<testcase name="testOne" file="%sIssue5561Test.php" line="21" class="PHPUnit\TestFixture\Issue5561\Issue5561Test" classname="PHPUnit.TestFixture.Issue5561.Issue5561Test" assertions="0" time="%s">
<failure type="PHPUnit\Framework\ExpectationFailedException">PHPUnit\TestFixture\Issue5561\Issue5561Test::testOne%A
Expand Down
2 changes: 1 addition & 1 deletion tests/end-to-end/regression/5771.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require_once __DIR__ . '/../../bootstrap.php';
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
--EXPECTF--
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuites name="PHPUnit tests">
<testsuite name="PHPUnit\TestFixture\Issue5771\Issue5771Test" file="%sIssue5771Test.php" tests="1" assertions="0" errors="1" failures="0" skipped="0" time="%s">
<testcase name="testOne" file="%sIssue5771Test.php" line="18" class="PHPUnit\TestFixture\Issue5771\Issue5771Test" classname="PHPUnit.TestFixture.Issue5771.Issue5771Test" assertions="0" time="%s">
<error type="PHPUnit\Framework\AssertionFailedError">PHPUnit\TestFixture\Issue5771\Issue5771Test::testOne%A
Expand Down

0 comments on commit 1ec05a4

Please sign in to comment.