How to execute parallel junit tests with maven surefire



  • 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? Thank you very much for your time!

    <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>
    


  • 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)



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2