--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to testng...@googlegroups.com.
To unsubscribe from this group, send email to testng-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.
I would be very interested in seeing the scope attribute to the
listeners field.. would this also apply the the xml? (ie if i put the
<listener> under the <test> xml it would be used only for that test?)
public class MyFunkyListener implements IInvokedMethodListener{
@Override
public void beforeInvocation(IInvokedMethod iInvokedMethod, ITestResult iTestResult) {
Annotation a = iInvokedMethod.getTestMethod().getRealClass().getAnnotation(Listeners.class);
if (a == null) {
return;
}
}
@Override
public void afterInvocation(IInvokedMethod iInvokedMethod, ITestResult iTestResult) {
}
}
--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
To post to this group, send email to testng...@googlegroups.com.
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
@Override
public void beforeInvocation(IInvokedMethod method, ITestResult testResult) {
Class realClass = method.getTestMethod().getRealClass();
Listeners annotation = (Listeners) realClass.getAnnotation(Listeners.class);
if (annotation == null) {
return;
}
List<?> usedAnnotations = Arrays.asList(annotation.value());
if (! usedAnnotations.contains(this.getClass())) {
System.err.println("Class doesn't need this listener to be executed");
}
}
Thanks for the reply. I don't think that will work for me, as I have 2 separate base classes for tests in my suite, and the different base classes both use listeners, just different sets of listeners. So I require a more specific check than "are there listener annotations defined".If scope, or similar, is added, I will gladly switch to use that.
--