Found the answer to my own question :) I had tried this briefly before posting my question, but it wasn't working for me. But I realize now that it's because our test framework is invoking junit differently than the default, so it wasn't calling the "suite" method that is needed in the following solution. In Eclipse, if I use the bundled junit runner to directly execute one Test/TestCase, it runs fine.
A way to do this setup/teardown once per class in junit 3 is to use TestSuite. Here's an example on junit.org:
public static Test suite() {
return new TestSetup(new TestSuite(YourTestClass.class)) {
protected void setUp() throws Exception {
System.out.println(" Global setUp ");
}
protected void tearDown() throws Exception {
System.out.println(" Global tearDown ");
}
};
}
http://stackoverflow.com/questions/1646586/class-teardown-in-junit-3
No comments:
Post a Comment