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

Commit cbf95f4

Browse files
committed
Fixed JUnit logger for PhpUnit 7.4+
1 parent 252a962 commit cbf95f4

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/Log/JUnit.php

100644100755
Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
use Codeception\Configuration;
55
use Codeception\Test\Interfaces\Reported;
66
use Codeception\Test\Test;
7+
use PHPUnit\Framework\TestCase;
78

89
class JUnit extends \PHPUnit\Util\Log\JUnit
910
{
@@ -39,6 +40,24 @@ public function endTest(\PHPUnit\Framework\Test $test, float $time):void
3940
$numAssertions
4041
);
4142
}
42-
parent::endTest($test, $time);
43+
44+
if ($test instanceof TestCase) {
45+
parent::endTest($test, $time);
46+
return;
47+
}
48+
49+
// since PhpUnit 7.4.0, parent::endTest ignores tests that aren't instances of TestCase
50+
// so I copied this code from PhpUnit 7.3.5
51+
52+
$this->currentTestCase->setAttribute(
53+
'time',
54+
\sprintf('%F', $time)
55+
);
56+
$this->testSuites[$this->testSuiteLevel]->appendChild(
57+
$this->currentTestCase
58+
);
59+
$this->testSuiteTests[$this->testSuiteLevel]++;
60+
$this->testSuiteTimes[$this->testSuiteLevel] += $time;
61+
$this->currentTestCase = null;
4362
}
4463
}

0 commit comments

Comments
 (0)