maven - surefire-plugin does not respect threadCount parameter -


since several days, tried see mistake in configuration run in parallel selenium tests.

i have selenium grid 2 nodes. in pom.xml, have set surefire run 2 2 methods of tests particular category other tests.

<build>     <plugins>         <plugin>             <groupid>org.apache.maven.plugins</groupid>             <artifactid>maven-surefire-plugin</artifactid>             <version>2.18.1</version>             <executions>                 <execution>                     <id>default-test</id>                     <goals>                         <goal>test</goal>                     </goals>                     <configuration>                         <parallel>methods</parallel>                         <percorethreadcount>false</percorethreadcount>                          <threadcount>2</threadcount>                         <reuseforks>false</reuseforks>                         <groups>                             com.something.categories.safe,                             com.something.categories.parallel                         </groups>                     </configuration>                 </execution>                 <execution>                     <id>no-safe</id>                     <goals>                         <goal>test</goal>                     </goals>                     <configuration>                         <excludedgroups>                             com.something.categories.safe,                             com.something.parallel                         </excludedgroups>                     </configuration>                 </execution>             </executions>         </plugin>     </plugins> </build> 

when launch test mvn clean test -dtest='testawesome' tests contains in testawesome launched in same time (i see more 2 browsers opended), , not respect threadcount value.

i'm missing something?

edition after answer here partial pom.xml solve issue

<profiles>     <profile>         <id>selenium-tests</id>         <activation>             <activebydefault>true</activebydefault>         </activation>         <build>             <plugins>                 <plugin>                     <groupid>org.apache.maven.plugins</groupid>                     <artifactid>maven-surefire-plugin</artifactid>                     <version>2.18.1</version>                     <configuration>                         <parallel>all</parallel>                         <threadcount>${threads}</threadcount>                         <percorethreadcount>false</percorethreadcount>                         <useunlimitedthreads>true</useunlimitedthreads>                         <systemproperties>                             <browser>${browser}</browser>                             <screenshotdirectory>${project.build.directory}/screenshots</screenshotdirectory>                             <gridurl>${seleniumgridurl}</gridurl>                             <env>${env}</env>                         </systemproperties>                         <groups>${groups}</groups>                         <excludedgroups>${excludedgroups}</excludedgroups>                     </configuration>                 </plugin>             </plugins>         </build>     </profile> </profiles> 

since using modern-enough version of surefire, might wanna try threadcountmethods parameter instead of threadcount in combination useunlimitedthreads = true, though seems counter-intuitive.

surefire junit examples:

as of surefire 2.7, no additional dependencies needed use full set of options parallel. of surefire 2.16, new thread-count attributes introduced, namely threadcountsuites, threadcountclasses , threadcountmethods.

fork options , parallel execution:

as example unlimited number of threads, there maximum of 3 concurrent threads execute suites: parallel = all, useunlimitedthreads = true, threadcountsuites = 3.


Comments