Using the JUnit assumeTrue, you can skip a test, but is there any way to tell JUnit that the test has been skipped? It seems to just report that the test has passed....
使用JUnit assumeTrue,您可以跳过测试,但有没有办法告诉JUnit已跳过测试?它似乎只是报告测试已通过....
Also, is there any way to detect during the @After method, if any tests have failed?
另外,有没有办法在@After方法中检测,如果有任何测试失败?
E.g.
@After
public void tearDown() {
//.... How many tests passed and how many failed?
}
I know this information is reported at the end of all the tests, but I would like to be able to access it in the @After function.
我知道在所有测试结束时会报告此信息,但我希望能够在@After函数中访问它。
1 个解决方案
#1
0
Also, is there any way to detect during the @After method, if any tests have failed?
另外,有没有办法在@After方法中检测,如果有任何测试失败?
You can implement your own Test Runner:
您可以实现自己的测试运行器:
@RunWith(MyRunner.class)
@See: org.junit.runners.BlockJUnit4ClassRunner
Or you can have a look at TestDecorators (in JUnit 4.7) junit.extensions.TestDecorator. That sounds like the thing you need, but I have no expirance with.
或者您可以查看TestDecorators(在JUnit 4.7中)junit.extensions.TestDecorator。这听起来像你需要的东西,但我没有任何过期。
#1
0
Also, is there any way to detect during the @After method, if any tests have failed?
另外,有没有办法在@After方法中检测,如果有任何测试失败?
You can implement your own Test Runner:
您可以实现自己的测试运行器:
@RunWith(MyRunner.class)
@See: org.junit.runners.BlockJUnit4ClassRunner
Or you can have a look at TestDecorators (in JUnit 4.7) junit.extensions.TestDecorator. That sounds like the thing you need, but I have no expirance with.
或者您可以查看TestDecorators(在JUnit 4.7中)junit.extensions.TestDecorator。这听起来像你需要的东西,但我没有任何过期。