admin管理员组文章数量:1356595
FailedRun.java:
package myrunner;
import .junit.runner.RunWith;
import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
@RunWith(Cucumber.class)
@CucumberOptions(features = {"target\\failedrerun.txt"},
glue = {"com.qa.stepDefinitions", "com.qa.hooks" },
stepNotifications = true,
plugin = {"pretty","com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:"},
monochrome = false,
dryRun = false)
public class FailedRun {
}
SuiteRunnerTest.java:
package myrunner;
import .junit.runner.RunWith;
import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
@RunWith(Cucumber.class)
@CucumberOptions(features = {"src/test/java/com/qa/features/Interactions.feature"},
glue = {"com.qa.stepDefinitions", "com.qa.hooks"},
tags = "@Test",
stepNotifications = true,
plugin = {
"pretty",
"com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:",
"rerun:target/failedrerun.txt"
},
monochrome = false,
dryRun = false)
public class SuiteRunnerTest {
}
pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns=".0.0"
xmlns:xsi=";
xsi:schemaLocation=".0.0 .0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>scmb</groupId>
<artifactId>SeleniumCucumberMBDD</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>SeleniumCucumberMBDD</name>
<url>;/url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<mavenpiler.source>17</mavenpiler.source>
<mavenpiler.target>17</mavenpiler.target>
</properties>
<dependencies>
<!-- Selenium -->
<dependency>
<groupId>.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.30.0</version>
</dependency>
<!-- WebDriver Manager -->
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>5.8.0</version>
</dependency>
<!-- Cucumber Dependencies -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>7.14.0</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>7.14.0</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-core</artifactId>
<version>7.14.0</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>7.14.0</version>
<scope>test</scope>
</dependency>
<!-- Test Framework -->
<dependency>
<groupId>.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.10.0</version>
<scope>test</scope>
</dependency>
<!-- Logging -->
<dependency>
<groupId>.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.9</version>
</dependency>
<dependency>
<groupId>.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.9</version>
</dependency>
<!-- Extent Reports -->
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>5.1.0</version>
</dependency>
<dependency>
<groupId>tech.grasshopper</groupId>
<artifactId>extentreports-cucumber7-adapter</artifactId>
<version>1.9.0</version>
</dependency>
<!-- Apache POI (Excel Handling) -->
<dependency>
<groupId>.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>5.2.3</version>
</dependency>
<!-- Java XML Bind -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
<!-- Lombok (For Cleaner Code) -->
<dependency>
<groupId>.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Maven Compiler Plugin -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
</plugin>
<!-- Maven Surefire Plugin (Runs JUnit Tests) -->
<plugin>
<groupId>.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.2</version>
<configuration>
<includes>
<include>**/SuiteRunnerTest.java</include>
<include>**/FailedRun.java</include>
</includes>
<!-- <rerunFailingTestsCount>1</rerunFailingTestsCount> -->
<!--<reuseForks>false</reuseForks>-->
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<!-- Profile for rerunning failed tests -->
<profile>
<id>rerun-failed</id>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
</plugin>
<plugin>
<groupId>.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.2</version>
<configuration>
<includes>
<include>**/target/failedrerun.txt</include>
</includes>
<exclude>**/SuiteRunnerTest.java</exclude>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
maven commands in cmd that I used:
mvn test -Dcucumber.features=target\\failedrerun.txt
mvn test -Dcucumber.features="target\\failedrerun.txt"
mvn test -Dcucumber.options="@target/failedrerun.txt"
Warnings I get:
Mar 28, 2025 2:59:17 PM io.cucumber.core.runtime.FeaturePathFeatureSupplier get
WARNING: No features found at file:/E:/Programming/workspace/SeleniumCucumberMBDD2/target/failedrerun.txt
Mar 28, 2025 2:59:18 PM io.cucumber.core.runtime.FeaturePathFeatureSupplier get
WARNING: No features found at file:/E:/Programming/workspace/SeleniumCucumberMBDD2/target/failedrerun.txt
Mar 28, 2025 2:59:18 PM io.cucumber.core.runtime.FeaturePathFeatureSupplier get
WARNING: No features found at file:/E:/Programming/workspace/SeleniumCucumberMBDD2/target/failedrerun.txt
Mar 28, 2025 2:59:18 PM io.cucumber.core.runtime.FeaturePathFeatureSupplier get
WARNING: No features found at file:/E:/Programming/workspace/SeleniumCucumberMBDD2/target/failedrerun.txt
Issue: When I tried to rerun the failed testcases, the cucumber couldn't identify the feature file scenario path in the failedrerun.txt text file. And after every time I tried to run, it shows the above-mentioned warnings and clears the failedrerun.txt file. The problem is when I mention the failedrerun.txt in plugin = {"rerun: target/failedrerun.txt"} and run the command "mvn test -Dcucumber.features="@target/failedrerun.txt" -Dtest=FailedRun" then it first erasing content of failedrerun.txt and then trying to start the execution.
FailedRun.java:
package myrunner;
import .junit.runner.RunWith;
import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
@RunWith(Cucumber.class)
@CucumberOptions(features = {"target\\failedrerun.txt"},
glue = {"com.qa.stepDefinitions", "com.qa.hooks" },
stepNotifications = true,
plugin = {"pretty","com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:"},
monochrome = false,
dryRun = false)
public class FailedRun {
}
SuiteRunnerTest.java:
package myrunner;
import .junit.runner.RunWith;
import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
@RunWith(Cucumber.class)
@CucumberOptions(features = {"src/test/java/com/qa/features/Interactions.feature"},
glue = {"com.qa.stepDefinitions", "com.qa.hooks"},
tags = "@Test",
stepNotifications = true,
plugin = {
"pretty",
"com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:",
"rerun:target/failedrerun.txt"
},
monochrome = false,
dryRun = false)
public class SuiteRunnerTest {
}
pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache./POM/4.0.0"
xmlns:xsi="http://www.w3./2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache./POM/4.0.0 http://maven.apache./xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>scmb</groupId>
<artifactId>SeleniumCucumberMBDD</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>SeleniumCucumberMBDD</name>
<url>http://www.example</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<mavenpiler.source>17</mavenpiler.source>
<mavenpiler.target>17</mavenpiler.target>
</properties>
<dependencies>
<!-- Selenium -->
<dependency>
<groupId>.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.30.0</version>
</dependency>
<!-- WebDriver Manager -->
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>5.8.0</version>
</dependency>
<!-- Cucumber Dependencies -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>7.14.0</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>7.14.0</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-core</artifactId>
<version>7.14.0</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>7.14.0</version>
<scope>test</scope>
</dependency>
<!-- Test Framework -->
<dependency>
<groupId>.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.10.0</version>
<scope>test</scope>
</dependency>
<!-- Logging -->
<dependency>
<groupId>.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.9</version>
</dependency>
<dependency>
<groupId>.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.9</version>
</dependency>
<!-- Extent Reports -->
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>5.1.0</version>
</dependency>
<dependency>
<groupId>tech.grasshopper</groupId>
<artifactId>extentreports-cucumber7-adapter</artifactId>
<version>1.9.0</version>
</dependency>
<!-- Apache POI (Excel Handling) -->
<dependency>
<groupId>.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>5.2.3</version>
</dependency>
<!-- Java XML Bind -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
<!-- Lombok (For Cleaner Code) -->
<dependency>
<groupId>.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Maven Compiler Plugin -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
</plugin>
<!-- Maven Surefire Plugin (Runs JUnit Tests) -->
<plugin>
<groupId>.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.2</version>
<configuration>
<includes>
<include>**/SuiteRunnerTest.java</include>
<include>**/FailedRun.java</include>
</includes>
<!-- <rerunFailingTestsCount>1</rerunFailingTestsCount> -->
<!--<reuseForks>false</reuseForks>-->
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<!-- Profile for rerunning failed tests -->
<profile>
<id>rerun-failed</id>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
</plugin>
<plugin>
<groupId>.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.2</version>
<configuration>
<includes>
<include>**/target/failedrerun.txt</include>
</includes>
<exclude>**/SuiteRunnerTest.java</exclude>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
maven commands in cmd that I used:
mvn test -Dcucumber.features=target\\failedrerun.txt
mvn test -Dcucumber.features="target\\failedrerun.txt"
mvn test -Dcucumber.options="@target/failedrerun.txt"
Warnings I get:
Mar 28, 2025 2:59:17 PM io.cucumber.core.runtime.FeaturePathFeatureSupplier get
WARNING: No features found at file:/E:/Programming/workspace/SeleniumCucumberMBDD2/target/failedrerun.txt
Mar 28, 2025 2:59:18 PM io.cucumber.core.runtime.FeaturePathFeatureSupplier get
WARNING: No features found at file:/E:/Programming/workspace/SeleniumCucumberMBDD2/target/failedrerun.txt
Mar 28, 2025 2:59:18 PM io.cucumber.core.runtime.FeaturePathFeatureSupplier get
WARNING: No features found at file:/E:/Programming/workspace/SeleniumCucumberMBDD2/target/failedrerun.txt
Mar 28, 2025 2:59:18 PM io.cucumber.core.runtime.FeaturePathFeatureSupplier get
WARNING: No features found at file:/E:/Programming/workspace/SeleniumCucumberMBDD2/target/failedrerun.txt
Issue: When I tried to rerun the failed testcases, the cucumber couldn't identify the feature file scenario path in the failedrerun.txt text file. And after every time I tried to run, it shows the above-mentioned warnings and clears the failedrerun.txt file. The problem is when I mention the failedrerun.txt in plugin = {"rerun: target/failedrerun.txt"} and run the command "mvn test -Dcucumber.features="@target/failedrerun.txt" -Dtest=FailedRun" then it first erasing content of failedrerun.txt and then trying to start the execution.
Share Improve this question edited Apr 1 at 9:08 Bobby Brahmam asked Mar 28 at 9:51 Bobby BrahmamBobby Brahmam 313 bronze badges 3 |1 Answer
Reset to default 0For the execution of failed scenario from the .txt file generated by cucumber, you need to provide the value of features option in Cucumber Options like this @target/failedrerun.txt
And no need to pass cucumber option from mvn command
本文标签:
版权声明:本文标题:java - Not able to rerun the failed testcases in selenium cucumber with junit using mvn test command from cmd - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744045114a2581378.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
SuiteRunnerTest
look like? – M.P. Korstanje Commented Mar 31 at 9:03