Trouble getting Selenium Server setup to run with JUnit

0 views
Skip to first unread message

Carlton

unread,
May 18, 2007, 10:24:22 AM5/18/07
to selenium-users...@googlegroups.com
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

Carlton

unread,
May 18, 2007, 11:17:10 AM5/18/07
to selenium-users...@googlegroups.com
The issue appears to have been that the GoogleTest class I was calling had a testGoogle() function but JUnit wanted it implement runTest(). Not sure why it worked fine standalone and not in a suite, but that was the issue.

Reply all
Reply to author
Forward
0 new messages