我有一系列数据,每个数据都包含 info_A 和 info_B。我愿意:
if(info_A) {
run Test A
} else if(!info_A) {
run Test B
}
只有实际运行的测试才会显示在 JUnit GUI 树中,这一点非常重要。我怎样才能做到这一点?
以下解决方案不有效:
- 如果我使用
Assume.assumeTrue(conditon)
,我可以Ignore
一个测试,但它仍然显示测试。 - 这样做:
结果 result = JUnitCore.runClasses(TestStep1.class);
导致正确的结果,但 JUnit 树未构建。 - 使用@Catagories 还会显示失败 测试,这也是我不想要的。
最佳答案
您可以 use Assume
有条件地打开/关闭测试:
A set of methods useful for stating assumptions about the conditions in which a test is meaningful. A failed assumption does not mean the code is broken, but that the test provides no useful information.
关于java - JUNIT 条件测试可能吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16035973/