Reputation: 31
I am using Apache's Surefire JUnit plug-in for maven.
I would like to re-run a test suite in JUnit 3.x. This is possible easily in JUnit 4, which offers the 'Parameterized' annotation.
Do you know how I can do the same in JUnit 3.x?
My goal is to run the entire suite of tests twice so that two different test data can be seeded into all the tests.
Upvotes: 3
Views: 630
Reputation: 5813
In JUnit 3.x you can define your own test suite. If you add
public static Test suite()
method to yout JUnit class than JUnit will run all methods that are defined in the returned variable. You can look on JUnit and junit.framework.TestSuite - No runnable methods (to the question) or http://junit.org/apidocs/junit/framework/TestSuite.html
You can do also something like this:
public static Test suite() {
TestSuite suite = new TestSuite(YouTestClass.class);
suite.addTest(new TestSuite(YouTestClass.class)); //you want to run all twice
// suite.addTest(new YouTestClass("foo", 0);
// for (int i = 0; i < TEST_SETALL.length; i++) {
// suite.addTest(new YouTestClass("setAllTest",i ));
// }
Test setup = new TestSetup(suite) {
protected void setUp() throws Exception {
// do your one time set-up here!
}
protected void tearDown() throws Exception {
// do your one time tear down here!
}
};
return setup;
}
Upvotes: 3