What is the best way run a lot of integration tests using JUnit?
I crudely discovered that the code below can run all the tests... but it has a massive flaw. The tearDown() method in each of those classes is not called until they have all been run.
public class RunIntegrationTests extends TestSuite {
public RunIntegrationTests(){
}
public static void main (String[] args){
TestRunner.run(testSuite());
}
public static Test testSuite(){
TestSuite result = new TestSuite();
result.addTest(new TestSuite(AgreementIntegrationTest.class));
result.addTest(new TestSuite(InterestedPartyIntegrationTest.class));
result.addTest(new TestSuite(WorkIntegrationTest.class));
// further tests omitted for readability
return result;
}
}
The classes being run connect to the database, load an object, and display it in a JFrame. I overrode the setVisible method to enable testing. On our build machine, the java vm runs out of memory when running the code above as the objects it has to load from the database are pretty large. If the tearDown() method was called after each class finished it would solve the memory problems.
Is there a better way to run them? I'm having to use JUnit 3.8.2 by the way - we're still on Java 1.4 :(