1. Federico Silva Armas
  2. qunit-webdriver-runner

Wiki

Clone wiki

qunit-webdriver-runner / Home

Welcome

This is a very simple runner of QUnit tests that can be integrated into a Maven project.


How does it work?

  • The module assumes that all your javascript, html and css files (product and test) are included as resources.
  • At the beginning of your test, start a QunitWebDriver passing the class loaders that are capable of locating all your resources.
  • QunitWebDriver will start a Jetty webserver that can serve requests from the resource files.
  • QunitWebDriver will then download, configure and start an instance of FireFox browser using WebDriver.
  • Lastly, you call QunitWebDriver.runTest() passing the html page that will load qunit and run your tests.
  • QunitWebDriver checks the UI of the page to verify that no test has failed.


Pom.xml

Build or download the .jar and include it in your project (sorry, I don't have a Maven repo available!). In the sample below, I copied the .jar into the /lib folder of my project

        <dependency>
            <groupId>org.farmas</groupId>
            <artifactId>qunit-webdriver-runner</artifactId>
            <version>0.1</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/lib/qunit-webdriver-runner-0.1.jar</systemPath>
        </dependency>
        <dependency>
            <groupId>com.atlassian.selenium</groupId>
            <artifactId>atlassian-pageobjects-elements</artifactId>
            <version>2.1.0-m8</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>jetty</artifactId>
            <version>6.1.24</version>
            <scope>test</scope>
        </dependency>


Test

This is what a test looks like

public class QunitTest {

    public static QunitWebDriver driver;

    @BeforeClass
    public static void start() throws Exception
    {
        // these are the class loaders particular to my project
        driver = QunitWebDriver.start(
                        QunitTest.class.getClassLoader(), 
                        TagParser.class.getClassLoader()); 
    }

    @Test
    public void test()
    {
        driver.runTest("/spec.htm");
    }

    @AfterClass
    public static void stopServer() throws Exception
    {
        driver.stop();
    }
}


Sample

A sample project that uses the runner can be found here: https://bitbucket.org/farmas/confluence-tags-plugin


- Federico

Updated