Permalink
Browse files

Closes #2579

1 parent 947de2f commit f67121497ee8dbae74a463b141772c2b52ac7e95 @sebastianbergmann committed Mar 21, 2017
Showing with 39 additions and 32 deletions.
  1. +1 −0 ChangeLog-6.1.md
  2. +1 −0 src/Util/Log/JUnit.php
  3. +17 −17 tests/TextUI/log-junit.phpt
  4. +12 −12 tests/TextUI/testdox-xml.phpt
  5. +8 −3 tests/_files/StatusTest.php
View
@@ -11,6 +11,7 @@ All notable changes of the PHPUnit 6.1 release series are documented in this fil
* Implemented [#2541](https://github.com/sebastianbergmann/phpunit/issues/2541): Implement configuration option to ignore deprecated code from code coverage
* Implemented [#2546](https://github.com/sebastianbergmann/phpunit/issues/2546): Render `__FILE__` and `__DIR__` in `SKIPIF` section of PHPT tests
* Implemented [#2551](https://github.com/sebastianbergmann/phpunit/issues/2551): Allow directory traversal in `FILE_EXTERNAL` section of PHPT tests
+* Implemented [#2579](https://github.com/sebastianbergmann/phpunit/issues/2579): Added `classname` attribute to JUnit XML logfile
### Changed
@@ -322,6 +322,7 @@ public function startTest(Test $test)
$method = $class->getMethod($test->getName());
$testCase->setAttribute('class', $class->getName());
+ $testCase->setAttribute('classname', str_replace('\\', '.', $class->getName()));
$testCase->setAttribute('file', $class->getFileName());
$testCase->setAttribute('line', $method->getStartLine());
}
@@ -16,34 +16,34 @@ PHPUnit %s by Sebastian Bergmann and contributors.
.FEISRW 7 / 7 (100%)<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
- <testsuite name="StatusTest" file="%s/StatusTest.php" tests="7" assertions="2" errors="2" failures="2" skipped="2" time="%s">
- <testcase name="testSuccess" class="StatusTest" file="%s/StatusTest.php" line="%d" assertions="1" time="%s"/>
- <testcase name="testFailure" class="StatusTest" file="%s/StatusTest.php" line="%d" assertions="1" time="%s">
- <failure type="PHPUnit\Framework\ExpectationFailedException">StatusTest::testFailure
+ <testsuite name="vendor\project\StatusTest" file="%s/StatusTest.php" tests="7" assertions="2" errors="2" failures="2" skipped="2" time="%s">
+ <testcase name="testSuccess" class="vendor\project\StatusTest" classname="vendor.project.StatusTest" file="%s/StatusTest.php" line="%d" assertions="1" time="%s"/>
+ <testcase name="testFailure" class="vendor\project\StatusTest" classname="vendor.project.StatusTest" file="%s/StatusTest.php" line="%d" assertions="1" time="%s">
+ <failure type="PHPUnit\Framework\ExpectationFailedException">vendor\project\StatusTest::testFailure
Failed asserting that false is true.
%s/StatusTest.php:%d
</failure>
</testcase>
- <testcase name="testError" class="StatusTest" file="%s/StatusTest.php" line="%d" assertions="0" time="%s">
- <error type="Exception">StatusTest::testError
-Exception:%w
+ <testcase name="testError" class="vendor\project\StatusTest" classname="vendor.project.StatusTest" file="%s/StatusTest.php" line="%d" assertions="0" time="%s">
+ <error type="RuntimeException">vendor\project\StatusTest::testError
+RuntimeException:%w
%s/StatusTest.php:%d
</error>
</testcase>
- <testcase name="testIncomplete" class="StatusTest" file="%s/StatusTest.php" line="%d" assertions="0" time="%s">
+ <testcase name="testIncomplete" class="vendor\project\StatusTest" classname="vendor.project.StatusTest" file="%s/StatusTest.php" line="%d" assertions="0" time="%s">
<skipped/>
</testcase>
- <testcase name="testSkipped" class="StatusTest" file="%s/StatusTest.php" line="%d" assertions="0" time="%s">
+ <testcase name="testSkipped" class="vendor\project\StatusTest" classname="vendor.project.StatusTest" file="%s/StatusTest.php" line="%d" assertions="0" time="%s">
<skipped/>
</testcase>
- <testcase name="testRisky" class="StatusTest" file="%s/StatusTest.php" line="%d" assertions="0" time="%s">
+ <testcase name="testRisky" class="vendor\project\StatusTest" classname="vendor.project.StatusTest" file="%s/StatusTest.php" line="%d" assertions="0" time="%s">
<error type="PHPUnit\Framework\RiskyTestError">Risky Test
</error>
</testcase>
- <testcase name="testWarning" class="StatusTest" file="%s/StatusTest.php" line="%d" assertions="0" time="%s">
- <warning type="PHPUnit\Framework\Warning">StatusTest::testWarning
+ <testcase name="testWarning" class="vendor\project\StatusTest" classname="vendor.project.StatusTest" file="%s/StatusTest.php" line="%d" assertions="0" time="%s">
+ <warning type="PHPUnit\Framework\Warning">vendor\project\StatusTest::testWarning
%s/StatusTest.php:%d
</warning>
@@ -56,24 +56,24 @@ Time: %s, Memory: %s
There was 1 error:
-1) StatusTest::testError
-Exception:%w
+1) vendor\project\StatusTest::testError
+RuntimeException:%w
%s/StatusTest.php:%d
--
There was 1 warning:
-1) StatusTest::testWarning
+1) vendor\project\StatusTest::testWarning
%s/StatusTest.php:%d
--
There was 1 failure:
-1) StatusTest::testFailure
+1) vendor\project\StatusTest::testFailure
Failed asserting that false is true.
%s/StatusTest.php:%d
@@ -82,7 +82,7 @@ Failed asserting that false is true.
There was 1 risky test:
-1) StatusTest::testRisky
+1) vendor\project\StatusTest::testRisky
This test did not perform any assertions
ERRORS!
@@ -15,38 +15,38 @@ PHPUnit %s by Sebastian Bergmann and contributors.
.FEISRW 7 / 7 (100%)<?xml version="1.0" encoding="UTF-8"?>
<tests>
- <test className="StatusTest" methodName="testSuccess" prettifiedClassName="Status" prettifiedMethodName="Success" status="0" time="%s" size="-1" groups="default"/>
- <test className="StatusTest" methodName="testFailure" prettifiedClassName="Status" prettifiedMethodName="Failure" status="3" time="%s" size="-1" groups="default" exceptionLine="11" exceptionMessage="Failed asserting that false is true."/>
- <test className="StatusTest" methodName="testError" prettifiedClassName="Status" prettifiedMethodName="Error" status="4" time="%s" size="-1" groups="default" exceptionMessage=""/>
- <test className="StatusTest" methodName="testIncomplete" prettifiedClassName="Status" prettifiedMethodName="Incomplete" status="2" time="%s" size="-1" groups="default"/>
- <test className="StatusTest" methodName="testSkipped" prettifiedClassName="Status" prettifiedMethodName="Skipped" status="1" time="%s" size="-1" groups="default"/>
- <test className="StatusTest" methodName="testRisky" prettifiedClassName="Status" prettifiedMethodName="Risky" status="5" time="%s" size="-1" groups="default"/>
- <test className="StatusTest" methodName="testWarning" prettifiedClassName="Status" prettifiedMethodName="Warning" status="6" time="%s" size="-1" groups="default"/>
+ <test className="vendor\project\StatusTest" methodName="testSuccess" prettifiedClassName="vendor\project\Status" prettifiedMethodName="Success" status="0" time="%s" size="-1" groups="default"/>
+ <test className="vendor\project\StatusTest" methodName="testFailure" prettifiedClassName="vendor\project\Status" prettifiedMethodName="Failure" status="3" time="%s" size="-1" groups="default" exceptionLine="16" exceptionMessage="Failed asserting that false is true."/>
+ <test className="vendor\project\StatusTest" methodName="testError" prettifiedClassName="vendor\project\Status" prettifiedMethodName="Error" status="4" time="%s" size="-1" groups="default" exceptionMessage=""/>
+ <test className="vendor\project\StatusTest" methodName="testIncomplete" prettifiedClassName="vendor\project\Status" prettifiedMethodName="Incomplete" status="2" time="%s" size="-1" groups="default"/>
+ <test className="vendor\project\StatusTest" methodName="testSkipped" prettifiedClassName="vendor\project\Status" prettifiedMethodName="Skipped" status="1" time="%s" size="-1" groups="default"/>
+ <test className="vendor\project\StatusTest" methodName="testRisky" prettifiedClassName="vendor\project\Status" prettifiedMethodName="Risky" status="5" time="%s" size="-1" groups="default"/>
+ <test className="vendor\project\StatusTest" methodName="testWarning" prettifiedClassName="vendor\project\Status" prettifiedMethodName="Warning" status="6" time="%s" size="-1" groups="default"/>
</tests>
Time: %s, Memory: %s
There was 1 error:
-1) StatusTest::testError
-Exception:%s
+1) vendor\project\StatusTest::testError
+RuntimeException:%s
%s/StatusTest.php:%d
--
There was 1 warning:
-1) StatusTest::testWarning
+1) vendor\project\StatusTest::testWarning
%s/StatusTest.php:%d
--
There was 1 failure:
-1) StatusTest::testFailure
+1) vendor\project\StatusTest::testFailure
Failed asserting that false is true.
%s/StatusTest.php:%d
@@ -55,7 +55,7 @@ Failed asserting that false is true.
There was 1 risky test:
-1) StatusTest::testRisky
+1) vendor\project\StatusTest::testRisky
This test did not perform any assertions
ERRORS!
@@ -1,5 +1,10 @@
<?php
-class StatusTest extends \PHPUnit\Framework\TestCase
+namespace vendor\project;
+
+use PHPUnit\Framework\TestCase;
+use PHPUnit\Framework\Warning;
+
+class StatusTest extends TestCase
{
public function testSuccess()
{
@@ -13,7 +18,7 @@ public function testFailure()
public function testError()
{
- throw new \Exception;
+ throw new \RuntimeException;
}
public function testIncomplete()
@@ -32,6 +37,6 @@ public function testRisky()
public function testWarning()
{
- throw new PHPUnit\Framework\Warning;
+ throw new Warning;
}
}

0 comments on commit f671214

Please sign in to comment.