Regarding parallel execution in cucumber selenium

247 Views Asked by At

I would like to ask which approach is better to go ahead with forking or without forking using parallel methods approach as per below document:

https://maven.apache.org/surefire/maven-surefire-plugin/examples/fork-options-and-parallel-execution.html

Which parameters would be best to use in terms of performance improvement and better utilization of the available system resources?

Thanks, Ranjana

1

There are 1 best solutions below

1
UnknownBeast On

I believe that you must choose the TestNG Runner to run the cucumber scripts. Please find the sample code below. If cucumber options are needed then feel free to add those in the annotation.

import org.testng.annotations.DataProvider;
import io.cucumber.testng.AbstractTestNGCucumberTests;

    public class RunCucumberTest extends AbstractTestNGCucumberTests{

        @Override
        @DataProvider(parallel = true)
        public Object[][] scenarios() {
            return super.scenarios();
        }
    }

and then you can add the below configuration in POM.xml

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-failsafe-plugin</artifactId>
        <version>2.22.0</version>
        <executions>
            <execution>
                <goals>
                    <goal>integration-test</goal>
                    <goal>verify</goal>
                </goals>
              <configuration>
                 <parallel>classes</parallel>
                 <threadCount>4</threadCount>
              </configuration>
            </execution>
        </executions>
    </plugin>