Closed orcunbalcilar closed 1 year ago
Yeah, this was pretty intentional #2498.
As the warning in the logs and documentation advices, when using cucumber.features
any selectors from the JUnit Platform are ignored.
If you are using the JUnit Platform API you should use the DiscoverySelectors
from the JUnit Platform. If you are using the JUnit Platform Suite Engine, the dedicated @Select*
annotations from the JUnit suite api.
Thank you for your response. Sorry, I did not see duplicate issues.
Note: To anyone who have the same issue (in Junit5 rerun cucumber scenarios), you can find my solution below ---->
Add testng and cucumber-testng dependencies in test scope to pom.xml
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.7.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-testng</artifactId>
<version>7.11.1</version>
<scope>test</scope>
</dependency>
Create an TestNG Cucumber Suite class
import io.cucumber.testng.AbstractTestNGCucumberTests;
import io.cucumber.testng.CucumberOptions;
import org.testng.annotations.DataProvider;
@CucumberOptions(features = "@rerun.txt", glue = {"(your glue)"}, plugin = {
"pretty"}, monochrome = true)
public class RerunCucumberScenarios extends AbstractTestNGCucumberTests {
@DataProvider(parallel = true)
@Override
public Object[][] scenarios() {
return super.scenarios();
}
}
Force maven surefire plugin to use TestNG auto detection provider by creating maven profiles.
<profiles>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.1.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>rerun</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.1.2</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-testng</artifactId>
<version>3.1.2</version>
</dependency>
</dependencies>
<configuration>
<properties>
<property>
<name>dataproviderthreadcount</name>
<value>${threadCount}</value>
</property>
</properties>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
Execute maven goal
mvn clean test -Dtest=RerunCucumberScenarios -DthreadCount=3 -P rerun //You are free to set any value to threadCount property. But cucumber.execution.parallel.config.fixed.parallelism ( or any other property that specifies the thread count in junit-platform.properties file) property value is recommended.
mvn clean test -Dcucumber.features="path/to/features" //This goal is for running all cucumber scenarios in your project. After this execution, you can execute the goal above to run the failed scenarios again.
Hi,
JUnit platform engine does not support rerunning failed scenarios by taking .txt execution result. Instead, it advices using Launcher API to run features and rerun failed scenarios. But in this case, if the cucumber.features property in the junit-platform. properties file is the same as the one on the launcher configuration, all the scenarios runs twice. Then it leads to duplicate execution and long lasting test time.
Is it working like this or can we take it as a bug?