package io.qameta.allure.junit4;

import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.junit.runner.notification.RunNotifier;

/**
 * @author Egor Borisov ehborisov@gmail.com
 */
@Aspect
public class AllureJunit4ListenerAspect {

    private final AllureJunit4 allure = new AllureJunit4();

    @AfterReturning(pointcut = "call(org.junit.runner.notification.RunNotifier.new(..))", returning = "notifier")
    public void addListener(final RunNotifier notifier) {
        notifier.removeListener(allure);
        notifier.addListener(allure);
    }

}

@@ -27,16 +27,51 @@
 unit4;%0A%0A
+import org.aspectj.lang.JoinPoint;%0A
 import o
@@ -102,25 +102,16 @@
 on.After
-Returning
 ;%0Aimport
@@ -376,34 +376,19 @@
 fter
-Returning(pointcut = %22call
+(%22execution
 (org
@@ -434,37 +434,11 @@
 new(
-..
 ))%22
-, returning = %22notifier%22
 )%0A  
@@ -473,31 +473,94 @@
 nal 
-RunNotifier notifier) %7B
+JoinPoint point) %7B%0A        final RunNotifier notifier = (RunNotifier) point.getThis();
 %0A   

fix junit4 aspect for gradle tests (via #111)