diff --git a/allure-junit4-aspect/src/main/java/io/qameta/allure/junit4/AllureJunit4ListenerAspect.java b/allure-junit4-aspect/src/main/java/io/qameta/allure/junit4/AllureJunit4ListenerAspect.java index 5d68d5d20..3ffd3641f 100644 --- a/allure-junit4-aspect/src/main/java/io/qameta/allure/junit4/AllureJunit4ListenerAspect.java +++ b/allure-junit4-aspect/src/main/java/io/qameta/allure/junit4/AllureJunit4ListenerAspect.java @@ -1,6 +1,7 @@ package io.qameta.allure.junit4; -import org.aspectj.lang.annotation.AfterReturning; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.annotation.After; import org.aspectj.lang.annotation.Aspect; import org.junit.runner.notification.RunNotifier; @@ -12,8 +13,9 @@ 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) { + @After("execution(org.junit.runner.notification.RunNotifier.new())") + public void addListener(final JoinPoint point) { + final RunNotifier notifier = (RunNotifier) point.getThis(); notifier.removeListener(allure); notifier.addListener(allure); }