I have a cucumber suite project which runs on top of Junit. I have updated the version from junit 4 to 5 and cucumber 4 to 7 both are BOM dependencies. In Junit-4 I was using cucumber-jvm-parallel-plugin - 5 Which was helping me to run cases in parallel since Junit 5 supports parallel executions I have updated the suite. I have achived the parallel executions.
The problem I am facing is I have 100 test case in total and 10 feature files each has 10 cases for an example if I am running @tagtwo which is running 10 cases but the maven result is
Tests run: 100, Failures: 0, Errors: 0, Skipped: 90
Where I should get
Tests run: 10, Failures: 0, Errors: 0, Skipped: 0
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>${junit.jupiter.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-bom</artifactId>
<version>${cucumber.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit-platform-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-suite</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
I have two Runner files RunCucumberTest is for running Dry which will run in surefire:test phase and RunCucumberIT will run in failsafe:verify phase I tried all methods and plugin for building the project but none of them worked
The cmd I use to run the suite is mvn clean verify "-Dcucumber.filter.tags=@one"
Please Let me know if any details need to be attached. Thanks in advance.
As you upgraded from JUnit 4 to JUnit 5, you'll want to give Cucumber JUnit Platform Engine - README a good read from top to bottom.
But in short, JUnit 5 comes with a Platform for writing Test Engines. The platform takes care of test discovery, selection and execution. So Cucumber uses the cucumber.filter.tags
property to skip tests at runtime because selecting and filtering tests should be done through JUnit.
To do that you can now use JUnit 5 tag expressions instead of Cucumber tag expressions. JUnit 5 tag expressions have a different syntax for combining tags and do not include the @
symbol.
You can pass a JUnit 5 tag expression to Maven using the groups
and excludedGroups
properties. For example:
mvn verify -DexcludedGroups="Ignore" -Dgroups="Smoke | Sanity"
Would exclude all scenarios tagged with @Ignore
and include all scenarios tagged with either @Smoke
and/or @Sanity
.
On your @Suite
annotated class you can also use JUnits @IncludeTags
and @ExcludeTags
annotations to exclude scenarios.