Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/386.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在Aspectj中为testsuite中的每个Junit测试创建切入点_Java_Junit_Aop_Aspectj - Fatal编程技术网

Java 在Aspectj中为testsuite中的每个Junit测试创建切入点

Java 在Aspectj中为testsuite中的每个Junit测试创建切入点,java,junit,aop,aspectj,Java,Junit,Aop,Aspectj,您好,我在集成AspectJ和Junit测试时遇到问题 我需要为testsuite中的每个测试获取不同的日志。所以我需要在我的方面知道新的测试用例何时运行,何时完成。我如何定义这样的切入点 下面的切入点对我不起作用,只是输入了一次 pointcut testIsAboutToBegin() : execution (* *.test(..)); 用一个迂回的建议怎么样 pointcut aroundTest(): execution(public void test*(..));

您好,我在集成AspectJ和Junit测试时遇到问题

我需要为testsuite中的每个测试获取不同的日志。所以我需要在我的方面知道新的测试用例何时运行,何时完成。我如何定义这样的切入点

下面的切入点对我不起作用,只是输入了一次

pointcut testIsAboutToBegin()
: execution (* *.test(..));

用一个迂回的建议怎么样

pointcut aroundTest(): 
    execution(public void test*(..));

  void around() throws Exception: aroundTest() {
     LOG.info("start");
     proceed();
     LOG.info("stop");
  }

您好如果要使用before()和after(),请尝试以下方法:

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*(..));

如果可以通过使用方法setUp()与JUnit4@Before或JUnit3中的pendant一起使用,为什么要使用方面?因为我正在使用方面跟踪每个测试用例的方法调用,我需要知道何时启动新跟踪。好的,但是您也可以在tearDown()方法中触发启动新跟踪(或者在JUnit4中用@After注释)@Nicolas如果该问题与实际问题无关,请更新或删除该问题,不要将其视为公开问题。请删除该问题-它与实际问题无关。