serenity-bdd/serenity-cucumber-starter

parallel execution not working with serenity version 3.2.1

Opened this issue · 1 comments

Hi,

I am using serenity 3.2.1 version for parallel execution of feature files. Earlier it was working with 2.0.90. Please refer attached pom.xml.

serenity 2.0.90 version pom.xml

4.0.0 org.example new-artifact 1.0-SNAPSHOT jar New Project
<properties>
	<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	<serenity.version>2.0.90</serenity.version>
	<serenity.maven.version>2.0.90</serenity.maven.version>
	<serenity.cucumber.version>1.0.29</serenity.cucumber.version>
	<cucumber.version>4.8.0</cucumber.version>
	<serenity.database.version>2.10.1</serenity.database.version>
	<browserstack.local.version>1.0.3</browserstack.local.version>
	<serenity.logs>1.2.3</serenity.logs>
	<jersey.version>1.19.4</jersey.version>
	<serenity.jira>1.12.0</serenity.jira>
	<apache.maven.plugins>3.0.0-M4</apache.maven.plugins>
	<encoding>UTF-8</encoding>
	<tags></tags>
	<parallel.tests>20</parallel.tests>
	<webdriver.base.url></webdriver.base.url>
</properties>
<repositories>
	<repository>
		<snapshots>
			<enabled>false</enabled>
		</snapshots>
		<id>central</id>
		<name>bintray</name>
		<url>https://jcenter.bintray.com</url>
	</repository>
</repositories>
<pluginRepositories>
	<pluginRepository>
		<snapshots>
			<enabled>false</enabled>
		</snapshots>
		<id>central</id>
		<name>bintray-plugins</name>
		<url>https://jcenter.bintray.com</url>
	</pluginRepository>
</pluginRepositories>
<dependencies>
	<dependency>
		<groupId>ch.qos.logback</groupId>
		<artifactId>logback-classic</artifactId>
		<version>${serenity.logs}</version>
	</dependency>
	<dependency>
		<groupId>ch.qos.logback</groupId>
		<artifactId>logback-core</artifactId>
		<version>${serenity.logs}</version>
	</dependency>
	<!--
      - To use Cucumber 4, exclude the old Cucumber 2 cucumber-core dependency from the serenity-core dependency
      - and include the Cucumber 4 cucumber-java and cucumber-junit dependencies.
    -->
	<dependency>
		<groupId>net.serenity-bdd</groupId>
		<artifactId>serenity-core</artifactId>
		<version>${serenity.version}</version>
		<scope>test</scope>
		<exclusions>
			<exclusion>
				<groupId>io.cucumber</groupId>
				<artifactId>cucumber-core</artifactId>
			</exclusion>
		</exclusions>
	</dependency>
	<dependency>
		<groupId>io.cucumber</groupId>
		<artifactId>cucumber-java</artifactId>
		<version>${cucumber.version}</version>
	</dependency>
	<dependency>
		<groupId>io.cucumber</groupId>
		<artifactId>cucumber-junit</artifactId>
		<version>${cucumber.version}</version>
	</dependency>
	<dependency>
		<groupId>com.fasterxml.jackson.core</groupId>
		<artifactId>jackson-databind</artifactId>
		<version>${serenity.database.version}</version>
	</dependency>
	<dependency>
		<groupId>com.fasterxml.jackson.core</groupId>
		<artifactId>jackson-core</artifactId>
		<version>${serenity.database.version}</version>
	</dependency>
	<dependency>
		<groupId>com.fasterxml.jackson.core</groupId>
		<artifactId>jackson-annotations</artifactId>
		<version>${serenity.database.version}</version>
	</dependency>
	<dependency>
		<groupId>com.fasterxml.jackson.dataformat</groupId>
		<artifactId>jackson-dataformat-xml</artifactId>
		<version>${serenity.database.version}</version>
	</dependency>
	<dependency>
		<groupId>com.fasterxml</groupId>
		<artifactId>jackson-xml-databind</artifactId>
		<version>0.6.2</version>
	</dependency>
	<dependency>
		<groupId>org.apache.httpcomponents</groupId>
		<artifactId>httpclient</artifactId>
		<version>4.5.10</version>
	</dependency>
	<dependency>
		<groupId>org.apache.httpcomponents</groupId>
		<artifactId>httpcore</artifactId>
		<version>4.4.12</version>
	</dependency>
	<dependency>
		<groupId>org.apache.httpcomponents</groupId>
		<artifactId>httpmime</artifactId>
		<version>4.5.10</version>
	</dependency>
	<dependency>
		<groupId>io.dropwizard.metrics</groupId>
		<artifactId>metrics-httpclient</artifactId>
		<version>4.1.2</version>
	</dependency>
	<dependency>
		<groupId>net.sourceforge.jtds</groupId>
		<artifactId>jtds</artifactId>
		<version>1.3.1</version>
	</dependency>
	<dependency>
		<groupId>org.jdbi</groupId>
		<artifactId>jdbi</artifactId>
		<version>2.78</version>
	</dependency>
	<dependency>
		<groupId>com.sun.jersey</groupId>
		<artifactId>jersey-client</artifactId>
		<version>${jersey.version}</version>
	</dependency>
	<dependency>
		<groupId>com.sun.jersey</groupId>
		<artifactId>jersey-json</artifactId>
		<version>${jersey.version}</version>
	</dependency>
	<dependency>
		<groupId>log4j</groupId>
		<artifactId>log4j</artifactId>
		<version>1.2.17</version>
	</dependency>
	<dependency>
		<groupId>net.serenity-bdd</groupId>
		<artifactId>serenity-junit</artifactId>
		<version>${serenity.version}</version>
		<scope>test</scope>
	</dependency>
	<dependency>
		<groupId>net.serenity-bdd</groupId>
		<artifactId>serenity-spring</artifactId>
		<version>${serenity.version}</version>
		<scope>test</scope>
	</dependency>
	<dependency>
		<groupId>net.serenity-bdd</groupId>
		<artifactId>serenity-cucumber4</artifactId>
		<version>${serenity.cucumber.version}</version>
	</dependency>
	<dependency>
		<groupId>net.serenity-bdd</groupId>
		<artifactId>serenity-jira-plugin</artifactId>
		<version>${serenity.jira}</version>
	</dependency>
	<dependency>
		<groupId>net.serenity-bdd</groupId>
		<artifactId>serenity-jira-requirements-provider</artifactId>
		<version>${serenity.jira}</version>
	</dependency>
	<dependency>
		<groupId>net.serenity-bdd</groupId>
		<artifactId>serenity-rest-assured</artifactId>
		<version>${serenity.version}</version>
	</dependency>
	<dependency>
		<groupId>net.serenity-bdd</groupId>
		<artifactId>serenity-screenplay-rest</artifactId>
		<version>${serenity.version}</version>
	</dependency>
	<dependency>
		<groupId>net.serenity-bdd</groupId>
		<artifactId>serenity-screenplay-webdriver</artifactId>
		<version>${serenity.version}</version>
		<scope>test</scope>
	</dependency>
	<dependency>
		<groupId>org.apache.poi</groupId>
		<artifactId>poi</artifactId>
		<version>3.10-FINAL</version>
	</dependency>
	<dependency>
		<groupId>org.apache.poi</groupId>
		<artifactId>poi-ooxml</artifactId>
		<version>3.10-FINAL</version>
	</dependency>
	<dependency>
		<groupId>com.microsoft.sqlserver</groupId>
		<artifactId>mssql-jdbc</artifactId>
		<version>8.1.1.jre13</version>
	</dependency>
	<dependency>
		<groupId>org.apache.commons</groupId>
		<artifactId>commons-email</artifactId>
		<version>1.5</version>
	</dependency>
	<dependency>
		<groupId>com.sun.mail</groupId>
		<artifactId>smtp</artifactId>
		<version>1.6.4</version>
	</dependency>
	<dependency>
		<groupId>net.lingala.zip4j</groupId>
		<artifactId>zip4j</artifactId>
		<version>1.2.4</version>
	</dependency>
	<dependency>
		<groupId>junit</groupId>
		<artifactId>junit</artifactId>
		<version>4.12</version>
		<scope>test</scope>
	</dependency>
	<dependency>
		<groupId>org.assertj</groupId>
		<artifactId>assertj-core</artifactId>
		<version>3.6.2</version>
		<scope>test</scope>
	</dependency>
	<dependency>
		<groupId>org.hamcrest</groupId>
		<artifactId>hamcrest-all</artifactId>
		<version>1.3</version>
		<scope>test</scope>
	</dependency>
	<dependency>
		<groupId>net.serenity-bdd</groupId>
		<artifactId>serenity-emailer</artifactId>
		<version>${serenity.version}</version>
	</dependency>
	<dependency>
		<groupId>com.browserstack</groupId>
		<artifactId>browserstack-local-java</artifactId>
		<version>${browserstack.local.version}</version>
	</dependency>
	<dependency>
		<groupId>net.serenity-bdd</groupId>
		<artifactId>serenity-browserstack</artifactId>
		<version>${serenity.version}</version>
	</dependency>
	<dependency>
		<groupId>org.apache.maven.plugins</groupId>
		<artifactId>maven-failsafe-plugin</artifactId>
		<version>${apache.maven.plugins}</version>
		<scope>test</scope>
	</dependency>
	<dependency>
		<groupId>com.amazonaws</groupId>
		<artifactId>aws-java-sdk</artifactId>
		<version>1.11.163</version>
	</dependency>
	<dependency>
		<groupId>commons-io</groupId>
		<artifactId>commons-io</artifactId>
		<version>2.4</version>
	</dependency>
	<dependency>
		<groupId>se.sawano.java</groupId>
		<artifactId>alphanumeric-comparator</artifactId>
		<version>1.4.1</version>
	</dependency>
</dependencies>
<build>
	<plugins>
		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-clean-plugin</artifactId>
			<version>3.1.0</version>
			<configuration>
				<filesets>
					<fileset>
						<directory>${project.basedir}</directory>
						<includes>
							<include>**/*.tmp</include>
							<include>**/*.log</include>
						</includes>
						<excludes>
							<exclude>**/important.log</exclude>
							<exclude>**/another-important.log</exclude>
						</excludes>
						<followSymlinks>false</followSymlinks>
					</fileset>
				</filesets>
			</configuration>
		</plugin>
		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-surefire-plugin</artifactId>
			<version>${apache.maven.plugins}</version>
			<configuration>
				<skip>true</skip>
			</configuration>
		</plugin>
		<plugin>
			<artifactId>maven-failsafe-plugin</artifactId>
			<version>${apache.maven.plugins}</version>
			<configuration>
				<includes>
					<include>**/ParallelRunner*.java</include>
				</includes>
				<systemPropertyVariables>
					<webdriver.base.url>${webdriver.base.url}</webdriver.base.url>
				</systemPropertyVariables>
				<parallel>methods</parallel>
				<threadCount>${parallel.tests}</threadCount>
				<perCoreThreadCount>false</perCoreThreadCount>
				<!--                    <forkCount>${parallel.tests}</forkCount>-->
			</configuration>
			<executions>
				<execution>
					<goals>
						<goal>integration-test</goal>
						<goal>verify</goal>
					</goals>
				</execution>
			</executions>
		</plugin>
		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-compiler-plugin</artifactId>
			<version>3.8.0</version>
			<configuration>
				<source>1.8</source>
				<target>1.8</target>
			</configuration>
		</plugin>
		<plugin>
			<groupId>net.serenity-bdd.maven.plugins</groupId>
			<artifactId>serenity-maven-plugin</artifactId>
			<version>${serenity.maven.version}</version>
			<configuration>
				<tags>${tags}</tags>
			</configuration>
			<executions>
				<execution>
					<id>serenity-reports</id>
					<phase>post-integration-test</phase>
					<goals>
						<goal>aggregate</goal>
					</goals>
				</execution>
			</executions>
		</plugin>
	</plugins>
</build>

<profiles>
	<profile>
		<id>parallel</id>
		<build>
			<plugins>
				<plugin>
					<artifactId>maven-failsafe-plugin</artifactId>
					<version>${apache.maven.plugins}</version>
					<configuration>
						<includes>
							<include>**/ParallelRunner*.java</include>
						</includes>
						<systemPropertyVariables>
							<webdriver.base.url>${webdriver.base.url}</webdriver.base.url>
						</systemPropertyVariables>
						<parallel>methods</parallel>
						<threadCount>${parallel.tests}</threadCount>
						<perCoreThreadCount>false</perCoreThreadCount>
						<!--                            <forkCount>${parallel.tests}</forkCount>-->
					</configuration>
				</plugin>
			</plugins>
		</build>
	</profile>

	<profile>
		<id>single</id>
		<build>
			<plugins>
				<plugin>
					<artifactId>maven-failsafe-plugin</artifactId>
					<version>${apache.maven.plugins}</version>
					<configuration>
						<includes>
							<include>**/SingleRunner.java</include>
						</includes>
						<systemPropertyVariables>
							<webdriver.base.url>${webdriver.base.url}</webdriver.base.url>
						</systemPropertyVariables>
					</configuration>
				</plugin>
			</plugins>
		</build>
	</profile>
</profiles>

serenity 3.2.1 version pom.xml

4.0.0 org.example new-artifact 1.0-SNAPSHOT jar New Project UTF-8 3.2.1 2.1.0 3.2.1 2.1.0 7.0.0 2.10.1 1.0.3 1.2.10 1.19.4 1.12.0 3.0.0-M5 UTF-8 20 false central bintray https://jcenter.bintray.com false central bintray-plugins https://jcenter.bintray.com ch.qos.logback logback-classic ${serenity.logs} ch.qos.logback logback-core ${serenity.logs} net.serenity-bdd serenity-core ${serenity.version} test io.cucumber cucumber-java ${cucumber.version} io.cucumber cucumber-core ${cucumber.version} io.cucumber cucumber-junit ${cucumber.version} net.serenity-bdd serenity-junit ${serenity.version} test net.serenity-bdd serenity-cucumber 3.2.1 net.serenity-bdd serenity-screenplay-rest ${serenity.version} net.serenity-bdd serenity-screenplay-webdriver ${serenity.version} test net.serenity-bdd serenity-ensure ${serenity.version} test org.apache.poi poi 3.10-FINAL org.apache.poi poi-ooxml 3.10-FINAL net.lingala.zip4j zip4j 2.10.0 org.junit.platform junit-platform-launcher 1.8.2 test org.junit.jupiter junit-jupiter-engine 5.8.2 test org.junit.vintage junit-vintage-engine 5.8.2 test junit junit 4.13.2 test org.assertj assertj-core 3.6.2 test com.browserstack browserstack-local-java ${browserstack.local.version} net.serenity-bdd serenity-browserstack ${serenity.version} org.apache.maven.plugins maven-failsafe-plugin ${apache.maven.plugins} test com.amazonaws aws-java-sdk 1.12.198 net.serenity-bdd serenity-cucumber4 2.1.2 se.sawano.java alphanumeric-comparator 1.4.1 org.apache.maven.plugins maven-clean-plugin 3.1.0 ${project.basedir} **/*.tmp **/*.log **/important.log **/another-important.log false
		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-surefire-plugin</artifactId>
			<version>${apache.maven.plugins}</version>
			<configuration>
				<skip>true</skip>
			</configuration>
		</plugin>
		<plugin>
			<artifactId>maven-failsafe-plugin</artifactId>
			<version>${apache.maven.plugins}</version>
			<configuration>
				<includes>
					<include>**/ParallelRunner*.java</include>
				</includes>
				<systemPropertyVariables>
					<webdriver.base.url>${webdriver.base.url}</webdriver.base.url>
				</systemPropertyVariables>
				<parallel>methods</parallel>
				<forkCount>${parallel.tests}</forkCount>
			</configuration>
			<executions>
				<execution>
					<goals>
						<goal>integration-test</goal>
						<goal>verify</goal>
					</goals>
				</execution>
			</executions>
		</plugin>
		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-compiler-plugin</artifactId>
			<version>3.8.1</version>
			<configuration>
				<source>1.8</source>
				<target>1.8</target>
			</configuration>
		</plugin>
		<plugin>
			<groupId>net.serenity-bdd.maven.plugins</groupId>
			<artifactId>serenity-maven-plugin</artifactId>
			<version>${serenity.maven.version}</version>
			<configuration>
				<tags>${tags}</tags>
			</configuration>
			<executions>
				<execution>
					<id>serenity-reports</id>
					<phase>post-integration-test</phase>
					<goals>
						<goal>aggregate</goal>
					</goals>
				</execution>
			</executions>
		</plugin>
	</plugins>
</build>

<profiles>
	<profile>
		<id>parallel</id>
		<build>
			<plugins>
				<plugin>
					<artifactId>maven-failsafe-plugin</artifactId>
					<version>${apache.maven.plugins}</version>
					<configuration>
						<includes>
							<include>**/ParallelRunner*.java</include>
						</includes>
						<systemPropertyVariables>
							<webdriver.base.url>${webdriver.base.url}</webdriver.base.url>
						</systemPropertyVariables>
						<parallel>methods</parallel>
						<parallel>classes</parallel>
						<useUnlimitedThreads>true</useUnlimitedThreads>
						<!--<threadCount>${parallel.tests}</threadCount>
						<forkCount>${parallel.tests}</forkCount>-->
					</configuration>
				</plugin>
			</plugins>
		</build>
	</profile>

	<profile>
		<id>single</id>
		<build>
			<plugins>
				<plugin>
					<artifactId>maven-failsafe-plugin</artifactId>
					<version>${apache.maven.plugins}</version>
					<configuration>
						<includes>
							<include>**/SingleRunner*.java</include>
						</includes>
						<systemPropertyVariables>
							<webdriver.base.url>${webdriver.base.url}</webdriver.base.url>
						</systemPropertyVariables>
					</configuration>
				</plugin>
			</plugins>
		</build>
	</profile>
</profiles>

Runner File

import io.cucumber.junit.CucumberOptions;
import net.serenitybdd.cucumber.CucumberWithSerenity;
import org.junit.runner.RunWith;

@RunWith(CucumberWithSerenity.class)
@CucumberOptions(
features = "classpath:features",
glue = "com.abc.stepDefs",
tags = "@regression"
)

public class ParallelRunner {
}

Can someone please help me to understand how can I fix this.

It's a known cucumber 7 issue - in Cucumber 7 parallel execution doesn't seem to work the way it's supposed to according to the Cucumber docs.