From 7080741bd5a2baaf2b6a768e678589250d75a3de Mon Sep 17 00:00:00 2001 From: Artem Eroshenko Date: Wed, 19 Jul 2017 14:23:57 +0300 Subject: [PATCH] fix junit4 aspect for gradle tests (via #111) --- .../qameta/allure/junit4/AllureJunit4ListenerAspect.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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); }