Creating a pointcut in Aspectj for each Junit test in testuite

Hi, I find it difficult to integrate AspectJ with Junit testing.

I need to get a different log for each test in testuite. Therefore, I need to know in my aspect when a new test case starts and when it ends. How can I determine such a point crop?

The next pointcut does not work for me, it is just entered once.

pointcut testIsAboutToBegin() : execution (* *.test(..)); 
+4
source share
2 answers

How to use advice?

 pointcut aroundTest(): execution(public void test*(..)); void around() throws Exception: aroundTest() { LOG.info("start"); proceed(); LOG.info("stop"); } 
0
source

Hello, you should use before () and after () for this purpose, try the following:

 before () : testIsAboutToBegin() { System.out.println("starting test ... "); } after () : testIsAboutToBegin() { System.out.println("ending test ... "); } //for GetJUnit 4.x pointcut testJUnit4xIsAboutToBegin() : execution(@Test * *(..)) pointcut testIsAboutToBegin() : execution (* *.test*(..)); 
0
source

All Articles