@@ -25,6 +25,7 @@ class AllureAdapter implements PHPUnit_Framework_TestListener
25
25
//NOTE: here we implicitly assume that PHPUnit runs in single-threaded mode
26
26
private $ uuid ;
27
27
private $ suiteName ;
28
+ private $ methodName ;
28
29
29
30
/**
30
31
* Annotations that should be ignored by the annotaions parser (especially PHPUnit annotations)
@@ -152,8 +153,21 @@ public function addRiskyTest(PHPUnit_Framework_Test $test, Exception $e, $time)
152
153
*/
153
154
public function addSkippedTest (PHPUnit_Framework_Test $ test , Exception $ e , $ time )
154
155
{
156
+ $ shouldCreateStartStopEvents = false ;
157
+ if ($ test instanceof \PHPUnit_Framework_TestCase){
158
+ $ methodName = $ test ->getName ();
159
+ if ($ methodName !== $ this ->methodName ){
160
+ $ shouldCreateStartStopEvents = true ;
161
+ $ this ->startTest ($ test );
162
+ }
163
+ }
164
+
155
165
$ event = new TestCaseCanceledEvent ();
156
166
Allure::lifecycle ()->fire ($ event ->withException ($ e )->withMessage ($ e ->getMessage ()));
167
+
168
+ if ($ shouldCreateStartStopEvents && $ test instanceof \PHPUnit_Framework_TestCase){
169
+ $ this ->endTest ($ test , 0 );
170
+ }
157
171
}
158
172
159
173
/**
@@ -200,11 +214,14 @@ public function startTest(PHPUnit_Framework_Test $test)
200
214
if ($ test instanceof \PHPUnit_Framework_TestCase) {
201
215
$ suiteName = $ this ->suiteName ;
202
216
$ methodName = $ test ->getName ();
217
+ $ this ->methodName = $ methodName ;
203
218
$ event = new TestCaseStartedEvent ($ this ->uuid , get_class ($ test ) . T_DOUBLE_COLON . $ methodName );
204
- $ annotationManager = new Annotation \AnnotationManager (
205
- Annotation \AnnotationProvider::getMethodAnnotations ($ suiteName , $ methodName )
206
- );
207
- $ annotationManager ->updateTestCaseEvent ($ event );
219
+ if (class_exists ($ suiteName , false ) && method_exists ($ suiteName , $ methodName )) {
220
+ $ annotationManager = new Annotation \AnnotationManager (
221
+ Annotation \AnnotationProvider::getMethodAnnotations ($ suiteName , $ methodName )
222
+ );
223
+ $ annotationManager ->updateTestCaseEvent ($ event );
224
+ }
208
225
Allure::lifecycle ()->fire ($ event );
209
226
}
210
227
}
0 commit comments