5454final class Collector
5555{
5656 private readonly IssueFilter $ issueFilter ;
57- private int $ numberOfTests = 0 ;
58- private int $ numberOfTestsRun = 0 ;
59- private int $ numberOfAssertions = 0 ;
60- private bool $ prepared = false ;
61- private bool $ currentTestSuiteForTestClassFailed = false ;
57+ private int $ numberOfTests = 0 ;
58+ private int $ numberOfTestsRun = 0 ;
59+ private int $ numberOfAssertions = 0 ;
60+ private bool $ prepared = false ;
6261
6362 /**
6463 * @var non-negative-int
@@ -243,16 +242,10 @@ public function testSuiteStarted(TestSuiteStarted $event): void
243242 if (!$ testSuite ->isForTestClass ()) {
244243 return ;
245244 }
246-
247- $ this ->currentTestSuiteForTestClassFailed = false ;
248245 }
249246
250247 public function testSuiteFinished (TestSuiteFinished $ event ): void
251248 {
252- if ($ this ->currentTestSuiteForTestClassFailed ) {
253- return ;
254- }
255-
256249 $ testSuite = $ event ->testSuite ();
257250
258251 if ($ testSuite ->isWithName ()) {
@@ -266,6 +259,12 @@ public function testSuiteFinished(TestSuiteFinished $event): void
266259
267260 assert ($ test instanceof TestMethod);
268261
262+ foreach ($ this ->testFailedEvents as $ testFailedEvent ) {
263+ if ($ testFailedEvent ->test ()->isTestMethod () && $ testFailedEvent ->test ()->methodName () === $ test ->methodName ()) {
264+ return ;
265+ }
266+ }
267+
269268 PassedTests::instance ()->testMethodPassed ($ test , null );
270269
271270 return ;
@@ -306,8 +305,6 @@ public function testErrored(Errored $event): void
306305 {
307306 $ this ->testErroredEvents [] = $ event ;
308307
309- $ this ->currentTestSuiteForTestClassFailed = true ;
310-
311308 /*
312309 * @todo Eliminate this special case
313310 */
@@ -323,8 +320,6 @@ public function testErrored(Errored $event): void
323320 public function testFailed (Failed $ event ): void
324321 {
325322 $ this ->testFailedEvents [] = $ event ;
326-
327- $ this ->currentTestSuiteForTestClassFailed = true ;
328323 }
329324
330325 public function testMarkedIncomplete (MarkedIncomplete $ event ): void
0 commit comments