Skip to content

Commit 14110cc

Browse files
committed
JUnit: report Risky test consistently as an error
1 parent 5ce4160 commit 14110cc

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

src/Util/Log/JUnit.php

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -168,22 +168,11 @@ public function addIncompleteTest(Test $test, Throwable $t, float $time): void
168168
*/
169169
public function addRiskyTest(Test $test, Throwable $t, float $time): void
170170
{
171-
if (!$this->reportRiskyTests || $this->currentTestCase === null) {
171+
if (!$this->reportRiskyTests) {
172172
return;
173173
}
174174

175-
$error = $this->document->createElement(
176-
'error',
177-
Xml::prepareString(
178-
"Risky Test\n" .
179-
Filter::getFilteredStacktrace($t)
180-
)
181-
);
182-
183-
$error->setAttribute('type', get_class($t));
184-
185-
$this->currentTestCase->appendChild($error);
186-
175+
$this->doAddFault($test, $t, 'error');
187176
$this->testSuiteErrors[$this->testSuiteLevel]++;
188177
}
189178

tests/end-to-end/loggers/log-junit.phpt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ RuntimeException:%w
4040
<skipped/>
4141
</testcase>
4242
<testcase name="testRisky" class="PHPUnit\SelfTest\Basic\StatusTest" classname="PHPUnit.SelfTest.Basic.StatusTest" file="%s%eStatusTest.php" line="%d" assertions="0" time="%f">
43-
<error type="PHPUnit\Framework\RiskyTestError">Risky Test
43+
<error type="PHPUnit\Framework\RiskyTestError">PHPUnit\SelfTest\Basic\StatusTest::testRisky
44+
This test did not perform any assertions
45+
46+
%s%eStatusTest.php:%d
4447
</error>
4548
</testcase>
4649
<testcase name="testWarning" class="PHPUnit\SelfTest\Basic\StatusTest" classname="PHPUnit.SelfTest.Basic.StatusTest" file="%s%eStatusTest.php" line="%d" assertions="0" time="%f">
@@ -72,7 +75,10 @@ RuntimeException: error with custom message
7275
<skipped/>
7376
</testcase>
7477
<testcase name="testRiskyWithMessage" class="PHPUnit\SelfTest\Basic\StatusTest" classname="PHPUnit.SelfTest.Basic.StatusTest" file="%s%eStatusTest.php" line="%d" assertions="0" time="%f">
75-
<error type="PHPUnit\Framework\RiskyTestError">Risky Test
78+
<error type="PHPUnit\Framework\RiskyTestError">PHPUnit\SelfTest\Basic\StatusTest::testRiskyWithMessage
79+
This test did not perform any assertions
80+
81+
%s%eStatusTest.php:%d
7682
</error>
7783
</testcase>
7884
<testcase name="testWarningWithMessage" class="PHPUnit\SelfTest\Basic\StatusTest" classname="PHPUnit.SelfTest.Basic.StatusTest" file="%s%eStatusTest.php" line="%d" assertions="0" time="%f">

0 commit comments

Comments
 (0)