Selenium JUnit 4 Class Runner

This is a JUnit 4 class runner that:

  • Reduces some of the boiler-plate required to write integration tests for Selenium using JUnit 4
  • Make it easier to implement re-usable custom method rules
  • Write integration tests to run against multiple browsers

The code snippet below shows the step up and tear down required to create an integration test without the Selenium JUnit 4 Class Runner:

public void class GoogleHomePageITCase {

    private static Selenium server;
        
    @BeforeClass
    public void start() {
        server = new DefaultSelenium("localhost", 4444, "http://www.google.com", "*firefox");
        server.start();
    }
        
    @AfterClass
    public void stop() {
        server.stop();
    }
    .
    .
    .
}

The code snippet below demonstrates how the same can be achieved more cleanly with the Selenium JUnit 4 Class Runner:

@RunWith(SeleniumJUnit4ClassRunner.class)
@ServerConfiguration(browserURL = "http://www.google.com")
public void class GoogleHomePageITCase {

    @SeleniumServer
    public Selenium server;
    .
    .
    .
}

Usage

More detailed on how to use the Selenium JUnit 4 Class Runner can be found here.

Examples

To provide you with better understanding of some usages of the Selenium JUnit 4 Class Runner, you can take a look into the following examples:

Future Plans

  • 1.1.0 - Implement custom method rules