I'm setting up several Selenium tests to run in a test suite via JUnit but running into some issues. If I put the startup/shutdown of the Selenium Server into each of my test cases it works fine. If I try to setup a test suite that creates the Selenium Server once and cleans it up at the end of the test suite, however, it doesn't work properly, giving me the following error:
junit.framework.AssertionFailedError
at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22)
at junit.extensions.TestSetup$1.protect(TestSetup.java:19)
at junit.extensions.TestSetup.run(TestSetup.java:23)
My test harness code comes largely from {code:html}<a href="
http://www.cs.wm.edu/~noonan/junit/doc/faq/faq.htm#organize_3">here</a>{code} and is as follows:
public class AllTestsOneTimeSetup {
static SeleniumServer _server = null;
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(new GoogleTest());
TestSetup wrapper = new TestSetup(suite) {
protected void setUp() throws Exception{
oneTimeSetUp();
}
protected void tearDown() {
oneTimeTearDown();
}
};
return wrapper;
}
public static void oneTimeSetUp() throws Exception {
_server = new SeleniumServer(4444);
_server.start();
}
public static void oneTimeTearDown() {
if( _server!=null )
_server.stop();
}
}
Does anyone have any example code of successfully doing this type of thing or know any pitfalls as to why this might not be working for me? Thanks for your help