@@ -54,6 +54,7 @@ final class TestResultCollector
54
54
private array $ tests = [];
55
55
private ?TestStatus $ status = null ;
56
56
private ?Throwable $ throwable = null ;
57
+ private bool $ prepared = false ;
57
58
58
59
/**
59
60
* @throws EventFacadeIsSealedException
@@ -136,6 +137,7 @@ public function testPrepared(Prepared $event): void
136
137
137
138
$ this ->status = TestStatus::unknown ();
138
139
$ this ->throwable = null ;
140
+ $ this ->prepared = true ;
139
141
}
140
142
141
143
public function testErrored (Errored $ event ): void
@@ -146,6 +148,14 @@ public function testErrored(Errored $event): void
146
148
147
149
$ this ->status = TestStatus::error ($ event ->throwable ()->message ());
148
150
$ this ->throwable = $ event ->throwable ();
151
+
152
+ if (!$ this ->prepared ) {
153
+ $ test = $ event ->test ();
154
+
155
+ assert ($ test instanceof TestMethod);
156
+
157
+ $ this ->process ($ test );
158
+ }
149
159
}
150
160
151
161
public function testFailed (Failed $ event ): void
@@ -290,18 +300,11 @@ public function testFinished(Finished $event): void
290
300
291
301
assert ($ test instanceof TestMethod);
292
302
293
- if (!isset ($ this ->tests [$ test ->testDox ()->prettifiedClassName ()])) {
294
- $ this ->tests [$ test ->testDox ()->prettifiedClassName ()] = [];
295
- }
296
-
297
- $ this ->tests [$ test ->testDox ()->prettifiedClassName ()][] = new TestDoxTestMethod (
298
- $ test ,
299
- $ this ->status ,
300
- $ this ->throwable ,
301
- );
303
+ $ this ->process ($ test );
302
304
303
305
$ this ->status = null ;
304
306
$ this ->throwable = null ;
307
+ $ this ->prepared = false ;
305
308
}
306
309
307
310
/**
@@ -340,4 +343,17 @@ private function updateTestStatus(TestStatus $status): void
340
343
341
344
$ this ->status = $ status ;
342
345
}
346
+
347
+ private function process (TestMethod $ test ): void
348
+ {
349
+ if (!isset ($ this ->tests [$ test ->testDox ()->prettifiedClassName ()])) {
350
+ $ this ->tests [$ test ->testDox ()->prettifiedClassName ()] = [];
351
+ }
352
+
353
+ $ this ->tests [$ test ->testDox ()->prettifiedClassName ()][] = new TestDoxTestMethod (
354
+ $ test ,
355
+ $ this ->status ,
356
+ $ this ->throwable ,
357
+ );
358
+ }
343
359
}
0 commit comments