[英]JUnit suite runner to execute one method
I have a test suite that runs all test classes 我有一个可以运行所有测试类的测试套件
@RunWith(Suite.class)
@Suite.SuiteClasses({TestClass1.class, TestClass1.class})
}
public class AllTests extends TestCase {
public AllTests(String name) {
super(name);
}
public static TestSuite suite() {
TestSuite suite = new TestSuite("com.myapp.test.AllTests");
return suite;
}
}
is it possible to implement a custom runner that will run only one method, say "onlyMethodToRun", from every class in the suite? 是否有可能实现一个自定义运行程序,该自定义运行程序将从套件中的每个类仅运行一个方法,例如“ onlyMethodToRun”?
Yes. 是。
Suite.java
implements a test runner that examines the classes listed in @Suite.SuiteClasses
and uses RunnerBuilder
s to find every test method. Suite.java
实现了一个测试运行程序,该运行程序检查@Suite.SuiteClasses
列出的类,并使用RunnerBuilder
查找所有测试方法。 You should be able to reuse a lot of JUnit's code to implement a Runner
that instead only checks for a single method on every class and perhaps uses a subclass of BlockJUnit4ClassRunner
that overrides computeTestMethods
to only attempt a single method. 您应该能够重用许多JUnit的代码来实现
Runner
,该Runner
只会在每个类上检查单个方法,并且可能会使用BlockJUnit4ClassRunner
的子类,该子类将重写computeTestMethods
以便仅尝试单个方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.