0

I am trying to run my cucumber tests in parallel. At the moment they run sequentially and it takes an insane amount of time to run all the tests.

This is my current pom:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>Salesforce</groupId>
<artifactId>Salesforce</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<modules>
    <module>Cucumber</module>
</modules>

<properties>
    <maven.repo.url.releases>http://maven-repo2.iggroup.local:8081/nexus/content/repositories/ig.release
    </maven.repo.url.releases>
    <maven.repo.url.snapshots>http://maven-repo2.iggroup.local:8081/nexus/content/repositories/ig.snapshot
    </maven.repo.url.snapshots>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <cucumber.version>4.2.6</cucumber.version>
    <junit.version>4.12</junit.version>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
</properties>

<dependencies>
    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-picocontainer</artifactId>
        <version>1.2.5</version>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>${junit.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-java</artifactId>
        <version>${cucumber.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-junit</artifactId>
        <version>${cucumber.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.4.0</version>
    </dependency>
    <dependency>
        <groupId>org.jsoup</groupId>
        <artifactId>jsoup</artifactId>
        <version>1.11.2</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/javax.mail/javax.mail-api -->
    <dependency>
        <groupId>javax.mail</groupId>
        <artifactId>javax.mail-api</artifactId>
        <version>1.6.1</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/com.sun.mail/javax.mail -->
    <dependency>
        <groupId>com.sun.mail</groupId>
        <artifactId>javax.mail</artifactId>
        <version>1.6.1</version>
    </dependency>
    <dependency>
        <groupId>org.glassfish</groupId>
        <artifactId>javax.json</artifactId>
        <version>1.1.4</version>
    </dependency>
    <dependency>
        <groupId>com.googlecode.java-diff-utils</groupId>
        <artifactId>diffutils</artifactId>
        <version>1.2.1</version>
    </dependency>
    <dependency>
        <groupId>commons-collections</groupId>
        <artifactId>commons-collections</artifactId>
        <version>3.0</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>com.lazerycode.selenium</groupId>
            <artifactId>driver-binary-downloader-maven-plugin</artifactId>
            <version>1.0.17</version>
            <configuration>
                <!-- root directory that downloaded driver binaries will be stored in -->
                <rootStandaloneServerDirectory>./target/webdrivers</rootStandaloneServerDirectory>
                <!-- Where you want to store downloaded zip files -->
                <downloadedZipFileDirectory>./target/webdrivers</downloadedZipFileDirectory>
                <!-- Location of a custom repository map -->
                <customRepositoryMap>${project.basedir}/CustomRepositoryMap.xml</customRepositoryMap>
                <!-- This will ensure that the plugin only downloads binaries for the current OS, this will override anything specified in the <operatingSystems> configuration -->
                <onlyGetDriversForHostOperatingSystem>false</onlyGetDriversForHostOperatingSystem>
                <!-- If set to false will download every version available (Other filters will be taken into account -->
                <onlyGetLatestVersions>false</onlyGetLatestVersions>
                <!-- Operating systems you want to download binaries for (Only valid options are: windows, linux, osx) -->
                <operatingSystems>
                    <windows>false</windows>
                    <linux>true</linux>
                    <mac>false</mac>
                </operatingSystems>
                <!-- Provide a list of drivers and binary versions to download (this is a map so only one version can be specified per driver) -->
                <getSpecificExecutableVersions>
                    <googlechrome>LATEST</googlechrome>
                </getSpecificExecutableVersions>
                <!-- Download 32bit binaries -->
                <!--<thirtyTwoBitBinaries>false</thirtyTwoBitBinaries>-->
                <!-- Download 64bit binaries -->
                <!--<sixtyFourBitBinaries>true</sixtyFourBitBinaries>-->
            </configuration>
            <executions>
                <execution>
                    <id>driverdownload</id>
                    <goals>
                        <goal>selenium</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

        <!-- FOR PARALLELISM: -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>3.0.0-M3</version>
            <executions>
                <execution>
                    <goals>
                        <goal>integration-test</goal>
                    </goals>
                    <configuration>
                        <!-- UNCOMMENT - To add any exclusions if required -->
                        <!-- <excludes> <exclude>**/*IT*.java</exclude> </excludes> -->
                        <includes>
                            <!-- UNCOMMENT BELOW LINE - To execute feature files with a single
                               runner -->
                            <include>**/Default.java</include>

                            <!-- UNCOMMENT BELOW LINE - To execute feature files with multiple
                               runners -->
                            <!-- <include>**/*Runner.java</include> -->
                        </includes>
                        <!-- UNCOMMENT BELOW 3 LINES - To execute using parallel or combination
                           option -->
                        <parallel>methods</parallel>
                        <threadCount>2</threadCount>
                        <perCoreThreadCount>true</perCoreThreadCount>
                        <!-- UNCOMMENT BELOW 3 LINES - To execute using forking or combination
                           option -->
                        <!-- <forkCount>2</forkCount>
                        <reuseForks>true</reuseForks>
                        <reportsDirectory>${project.build.directory}/failsafe-reports_${surefire.forkNumber}</reportsDirectory> -->
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <!-- Used for reporting the output: -->
<!--            <plugin>-->

<!--                <groupId>com.trivago.rta</groupId>-->
<!--                <artifactId>cluecumber-report-plugin</artifactId>-->
<!--                <version>1.7.2</version>-->
<!--                <executions>-->
<!--                    <execution>-->
<!--                        <id>report</id>-->
<!--                        <phase>post-integration-test</phase>-->
<!--                        <goals>-->
<!--                            <goal>reporting</goal>-->
<!--                        </goals>-->
<!--                    </execution>-->
<!--                </executions>-->
<!--                <configuration>-->
<!--                    <sourceJsonReportDirectory>${project.build.directory}/json-cucumber-reports</sourceJsonReportDirectory>-->
<!--                    <generatedHtmlReportDirectory>${project.build.directory}/generated-report</generatedHtmlReportDirectory>-->

<!--                    <expandStepHooks>true</expandStepHooks>-->
<!--                </configuration>-->
<!--            </plugin>-->
        </plugins>
        <testSourceDirectory>src/test/java/runner</testSourceDirectory>
        <testResources>
            <testResource>
                <directory>src/test/resources/UAT_Regression

</directory>
        </testResource>
    </testResources>
</build>

<repositories>
    <!-- Sonatype OSS -->
    <repository>
        <id>sonatype</id>
        <name>Day CQ5 Repository (OSGI)</name>
        <url>http://maven-repo2.iggroup.local:8081/nexus/content/repositories/sonatype-oss</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
    <!-- Central mirror -->
    <repository>
        <id>central</id>
        <name>Day CQ5 Repository (OSGI)</name>
        <url>http://maven-repo2.iggroup.local:8081/nexus/content/repositories/central</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>atlassian-repo</id>
        <name>Day CQ5 Repository (OSGI)</name>
        <url>http://maven-repo2.iggroup.local:8081/nexus/content/repositories/atlassian.public</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
</repositories>

<pluginRepositories>
    <pluginRepository>
        <releases>
            <enabled>true</enabled>
            <updatePolicy>always</updatePolicy>
        </releases>
        <snapshots>
            <enabled>false</enabled>
            <updatePolicy>always</updatePolicy>
        </snapshots>
        <id>central</id>
        <url>http://maven-repo2.iggroup.local:8081/nexus/content/repositories/central</url>
    </pluginRepository>
</pluginRepositories>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.3.1</version>
        </dependency>
    </dependencies>
</dependencyManagement>

<distributionManagement>
    <repository>
        <id>ig.releases</id>
        <name>ig-repository</name>
        <url>${maven.repo.url.releases}</url>
    </repository>
    <snapshotRepository>
        <id>ig.snapshots</id>
        <name>ig-repository</name>
        <url>${maven.repo.url.snapshots}</url>
    </snapshotRepository>
</distributionManagement>

</project>

And my project directory pretty much contains: src/main/java/com/automation/cucumber and this directory contains 2 folders; Steps (contains the step definitions) and utils (Helper methods). And under src/main/test/resources/UAT_Regression I have my .feature files in here. My runner class is located under: src/test/java/runner/runner/RunCucumberIT.java

The above pom was coded to reflect what was in this repository as this had an example of cucumber tests running in parallel.

But when I try and run my runner class, it just pretty much runs them sequentially as opposed to parralelly so not sure why. Can anyone point out my mistake?

I am using WebDriver in my tests.

eghe
  • 137
  • 2
  • 14
  • Have you read that [similar question](https://stackoverflow.com/a/55309095/7736617) ? – Arnaud Claudel Aug 07 '19 at 15:23
  • Yes, I've tried that and get the following error: `org.apache.maven.surefire.util.SurefireReflectionException: java.lang.reflect.InvocationTargetException; nested exception is java.lang.reflect.InvocationTargetException: null ` – eghe Aug 07 '19 at 15:52
  • But I did try ` org.apache.maven.plugins maven-surefire-plugin 2.4.2 methods 10 ` and it runs but not parallel.. just sequentially so back to square one. – eghe Aug 07 '19 at 15:59
  • Do your tests run with fail-safe or sure-fire ? You can verify it in maven logs – Arnaud Claudel Aug 07 '19 at 16:07
  • @ArnaudClaudel I've been swapping between the two to get this working but currently in the logs, it says `[INFO] --- maven-failsafe-plugin:3.0.0-M3:integration-test (default) @ Salesforce ---[INFO] No tests to run.` so im assuming its sure-fire that is running the tests – eghe Aug 07 '19 at 16:22
  • Do you see them executed with sure fire ? Is your pom up-to-date ? – Arnaud Claudel Aug 07 '19 at 16:25
  • @ArnaudClaudel Yeah I see that surefire are executing the steps. My pom is up to date. – eghe Aug 07 '19 at 16:33
  • Then I think that your problem is because surefire runs the tests but only failsafe is configured for parallelism – Arnaud Claudel Aug 07 '19 at 16:40
  • U should look at the official docs - https://cucumber.io/docs/guides/parallel-execution/. Start with a simpler example especially the POM and then build on it. In the failsafe plugin u have included the class Default.java to run. That is why no tests are found. – Grasshopper Aug 07 '19 at 17:27

0 Answers0