Reputation: 1096
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?
Upvotes: 0
Views: 794
Reputation: 31110
Yes. Suite.java
implements a test runner that examines the classes listed in @Suite.SuiteClasses
and uses RunnerBuilder
s to find every test method. 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.
Upvotes: 1