I am building an automation framework using selenium, cucumber and trying to run my cucumber test cases in parallel. I am using the jvm.cucumber.parallel plugin for executing my test cases parallel. My POM file looks like this:
<?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>com.tests</groupId>
<artifactId>Sample-Cucumber</artifactId>
<version>1.0</version>
<name>Sample-Cucumber</name>
<description>Sample Automation with Cucumber Implementation</description>
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<cucumber.version>1.2.3</cucumber.version>
<extentreports.version>2.41.0</extentreports.version>
<selenium.version>2.53.1</selenium.version>
<cucumber.jvm.parallel.version>1.2.1</cucumber.jvm.parallel.version>
</properties>
<dependencies>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>${cucumber.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>1.7.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>${selenium.version}</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>${cucumber.version}</version>
</dependency>
<dependency>
<groupId>com.sitture</groupId>
<artifactId>cucumber-jvm-extentreport</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>org.apache.directory.studio</groupId>
<artifactId>org.apache.commons.codec</artifactId>
<version>1.8</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>com.vimalselvam</groupId>
<artifactId>cucumber-extentsreport</artifactId>
<version>1.1.1</version>
</dependency>
</dependencies>
<profiles>
<profile>
<id>win</id>
<activation>
<os>
<family>windows</family>
</os>
</activation>
<properties>
<webdriver.chrome.path>${basedir}${file.separator}resources${file.separator}chromedriver.exe</webdriver.chrome.path>
</properties>
</profile>
<profile>
<id>linux</id>
<activation>
<os>
<family>!windows</family>
</os>
</activation>
<properties>
<webdriver.chrome.path>resources${file.separator}chromedriver</webdriver.chrome.path>
</properties>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
</plugin>
<plugin>
<groupId>com.github.temyers</groupId>
<artifactId>cucumber-jvm-parallel-plugin</artifactId>
<version>${cucumber.jvm.parallel.version}</version>
<executions>
<execution>
<id>generateRunners</id>
<phase>test</phase>
<goals>
<goal>generateRunners</goal>
</goals>
<configuration>
<glue>src/test/java/com/cucumber/stepdefinitions/</glue>
<outputDirectory>${project.build.directory}/generated-test-sources/cucumber</outputDirectory>
<featuresDirectory>src/test/resources/features/</featuresDirectory>
<cucumberOutputDir>target/cucumber-parallel</cucumberOutputDir>
<format>json,html</format>
<strict>true</strict>
<monochrome>true</monochrome>
<tags>"~@ignore"</tags>
<filterFeaturesByTags>true</filterFeaturesByTags>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
<configuration>
<!-- Increase Fork Count to increase parallel execution count.
Currently it is set to 5 which means 5 runners will run in parallel-->
<forkCount>5</forkCount>
<reuseForks>true</reuseForks>
<includes>
<include>**/*IT.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
My runner files looks like this
package com.cucumber.runner.sample1;
import com.sitture.ExtentFormatter;
import com.tools.Constants;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
@RunWith(Cucumber.class)
@CucumberOptions(strict = true,features = { "classpath:features/Featureset1/" },
glue = { "com.cucumber.stepdefinitions" },
plugin = { "com.sitture.ExtentFormatter","pretty",
"html:target/cucumber-reports",
"json:target/cucumber.json",
"rerun:target/rerun.txt" },
tags={"~@skip"})
public class SampleRunner1IT {
@BeforeClass
public static void setup() {
//ExtentFormatter.initiateExtentFormatter();
ExtentFormatter.initiateExtentFormatter(new File(Constants.RESOURCES_PATH+"Reports.html"),false);
ExtentFormatter.loadConfig(new File(Constants.RESOURCES_PATH
+ "extent-config.xml"));
//ExtentFormatter.addSystemInfo("Browser", "Chrome");
ExtentFormatter.addSystemInfo("Selenium", "v2.53.1");
Map<String, String> systemInfo = new HashMap<String, String>();
systemInfo.put("Cucumber", "v1.2.5");
systemInfo.put("Extent Reports", "v2.41.1");
ExtentFormatter.addSystemInfo(systemInfo);
}
}
I have multiple similar runner files which use the same pattern except the path for feature files for features under @CucumberOptions
The problem is that when I do mvn clean install or mvn clean test it keeps overwriting the Reports.html file and also my rerun.txt file is overwritten.
I am relatively new to cucumber automation framework would like to run my cucumber test is parallel.