Reputation: 83
I am building a module that listens to TestNG tests and performs certain actions just before a test method starts its execution, for every test method. I just want to know when a test(method) starts its execution, name of the method and optionally name of the test class.
I was successfully able to write pointcuts for invoker calls of testNG. It worked.
@Pointcut("execution(* org.testng.internal.IInvoker.invokeTestMethods(..))")
Instead, I was wondering as every test method is annotated with @org.testng.annotations.Test
, how can I write pointcut to catch execution joinPoint of every test method annotated with @org.testng.annotations.Test
?
Here is how my test looks like
@BeforeClass
public void setup() {
//setup logic
}
@BeforeMethod
private void configure() {
//config logic
}
@Test
public void testLoad() {
//test
}
@Test
public void testForm() {
//test
}
I tried a few pointcuts, they turned out to be invalid ones. Note: I am using load time weaving.
Upvotes: 1
Views: 926
Reputation: 459
Try this
"execution(* *(..)) && @annotation(org.testng.annotations.Test)"
Upvotes: 4