Parallel Execution using Failsafe plugin
Running Cucumber Feature using Failsafe plugin in place of Maven Surefireplugin.
Maven Project Structure.
D:.
├───.settings
└───src
├───main
│ ├───java
│ │ └───parallelExecution
│ └───resources
└───test
├───java
│ ├───cucumberRunner
│ └───StepDefination
└───resources
└───parallel
We need to add the Failsafe plugin in POM.xml
Rename the runner class to RunCucumberIT
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.21.0</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<parallel>methods</parallel>
<useUnlimitedThreads>true</useUnlimitedThreads>
<include>**/*IT.java</include>
</configuration>
</execution>
</executions>
</plugin>
To set the thread count to a specific number instead of
useUnlimitedThreads use the below setting.<configuration>
<parallel>methods</parallel>
<threadCount>4</threadCount>
</configuration>The thread count in the above setting is 4 threads per core. If you want this to be 4 threads across all cores set the
perCoreThreadCount to false.<configuration>
<parallel>methods</parallel>
<threadCount>4</threadCount>
<perCoreThreadCount>false</perCoreThreadCount>
</configuration>In case of multiple runners one can also set the parallel option to classesAndMethods or classes in addition to methods.We need to create two runner class and distribute the feature file<configuration>
<parallel>classesAndMethods</parallel>
useUnlimitedThreads>true</useUnlimitedThreads>
</configuration>Parallel execution using fork count Mentioning Two Runner class in Pom.xml<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
<forkCount>7</forkCount>
<reuseForks>true</reuseForks>
<includes>
<include>**/RunCucumberIT.class</include>
<include>**/RunCucumberTwoIT.class</include>
</includes>
</configuration>
</plugin>
Comments
Post a Comment