I have an aspect that runs after an exception is thrown from my TestNG test method. I would like to get the Test method name into my aspectj method.
Any thoughts on this? Please find my code sample below:
Aspect:
pointcut publicCall(): call(public * *(..));
after() throwing (AssertionError e): publicCall() {
logger.debug("Assertion Error thrown");
System.out.println("Threw an exception: " + e);
}
Test:
@Test
public void testScenarioOne(){
logger.debug("From Scenario One Test");
Assert.assertEquals(true, false);
}
You need to change your pointcut type from
calltoexecution:Edit: Maybe it would be even cleaner to specifically intercept
@Testannotated methods: