你好,我在集成AspectJ和Junit测试时遇到了问题。
我需要为测试套件中的每个测试获取不同的日志。所以在我的方面,我需要知道新的测试用例什么时候运行,什么时候结束。我如何定义这样的点切割?
下面的切入点对我不起作用,它只需要输入一次。
pointcut testIsAboutToBegin()
: execution (* *.test(..));发布于 2013-06-11 20:27:55
使用一个周围的建议如何?
pointcut aroundTest():
execution(public void test*(..));
void around() throws Exception: aroundTest() {
LOG.info("start");
proceed();
LOG.info("stop");
}发布于 2014-07-14 22:24:39
您好,您应该使用之前()和之后()为此目的,尝试以下内容:
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*(..));https://stackoverflow.com/questions/15540441
复制相似问题