I have huge set of JUnits in my projects. Out of which, I would like to execute certain set by looking up the classes from a property file.
Prior to JUnit 4:
public class TestSuite { public static Test suite() { TestSuite suite = new TestSuite(); Class [] array = readFromPropertyFile(); for (Class tempClz : array) { suite.addTestSuite(tempClz); } } } However in Junit4, I'm forced to annotate the classes at compile time as follows:
@RunWith(Suite.class) @Suite.SuiteClasses({ Test1.class, Test2.class }) public class TestSuite { } I cannot, switch back to Junit 3.x because, all the test classes are no more extending TestCase meaning Test1.class is not of type Class<? extends TestCase>
Is there a way to dynamically configure the testsuite in this case ?
suite.addTestSuite(tempClz);expects tempClz to beClass<? extends TestCase>where I get an error (compile time).