How do I Dynamically create a Test Suite in JUnit 4?
问题 I would like to create a junit test suite using JUnit 4 where the names of the test classes to be included are not known until the test suite is run. In JUnit 3 I could do this: public final class MasterTester extends TestCase { /** * Used by junit to specify what TestCases to run. * * @return a suite containing what TestCases to run */ public static TestSuite suite() { TestSuite suite = new TestSuite(); for(Class<?> klass : gatherTestClasses()) { suite.addTestSuite(klass); } return suite; }