@@ -25,6 +25,7 @@ class AllureAdapter implements PHPUnit_Framework_TestListener
2525 //NOTE: here we implicitly assume that PHPUnit runs in single-threaded mode
2626 private $ uuid ;
2727 private $ suiteName ;
28+ private $ methodName ;
2829
2930 /**
3031 * 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)
152153 */
153154 public function addSkippedTest (PHPUnit_Framework_Test $ test , Exception $ e , $ time )
154155 {
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+
155165 $ event = new TestCaseCanceledEvent ();
156166 Allure::lifecycle ()->fire ($ event ->withException ($ e )->withMessage ($ e ->getMessage ()));
167+
168+ if ($ shouldCreateStartStopEvents && $ test instanceof \PHPUnit_Framework_TestCase){
169+ $ this ->endTest ($ test , 0 );
170+ }
157171 }
158172
159173 /**
@@ -200,11 +214,14 @@ public function startTest(PHPUnit_Framework_Test $test)
200214 if ($ test instanceof \PHPUnit_Framework_TestCase) {
201215 $ suiteName = $ this ->suiteName ;
202216 $ methodName = $ test ->getName ();
217+ $ this ->methodName = $ methodName ;
203218 $ 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+ }
208225 Allure::lifecycle ()->fire ($ event );
209226 }
210227 }
0 commit comments