3

I'm using Selenium WebDriver, Junit 4.9, maven for testing.

Now I need to parallel tests. I added the plugin below, then tried to run it from IntelliJ IDEA 11, but it was still running sequentially.

Is there anything wrong I did?

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.16</version>
        <configuration>
            <parallel>classes</parallel>
            <threadCount>3</threadCount>
        </configuration>
    </plugin>

3 Answers 3

2

Try again with the latest version of the maven-surefire-plugin. This is the config I am using which works fine

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.18.1</version>
    <configuration>
        <parallel>all</parallel>
        <threadCount>10</threadCount>
    </configuration>
</plugin>

Just keep in mind not to use non final static variables (if you really need them you could wrap them in a InheritableThreadLocal instance)

1

Try this http://groboutils.sourceforge.net/

The GroboUtils class MultiThreadedTestRunner was based on the article "JUnit Best Practices" by Andy Schneider ([email protected]), published online at http://www.javaworld.com/javaworld/jw-12-2000/jw-1221-junit_p.html. Since GroboUtils first started using that implementation, many changes have occured in the code to make a more robust and stable testing environment.

1

Alternative way to run in parallel is creating separate processes for each run instead of threads. It can be helpful when you are experiencing some synchronization issues or crashes. In this case create batch file and run all suites like:

start mvn integration-test -Dsuite="SomeSuite1"
start mvn integration-test -Dsuite="SomeSuite2"
start mvn integration-test -Dsuite="SomeSuite3"

Also you may need to have results stored in separate folders, edit pom.xml file:

<reportsDirectory>${project.build.directory}/report/${suite}</reportsDirectory>

If you wish to run the tests on CI and wait for all suites to finish, see solution here: Wait for multiple applications run asynchronously from batch file to finish

This approaches is not very "clear" and "from the box" but it saved me 40-50% of regression execution time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.