如何从Maven重新运行失败的Cucumber方案?

时间:2019-06-17 11:57:19

标签: maven cucumber testng

我正在尝试重新运行失败的黄瓜测试。我在框架中使用maven和TestNG。我该如何实现?

我已经使用<rerunFailingTestsCount>2</rerunFailingTestsCount>在我的POM中尝试了maven-surefire-plugin(版本:3.0.0-M3)。但这不会在测试失败时自动重新运行测试。

POM代码段

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
<configuration>
<!-- <suiteXmlFiles>testNG.xml</suiteXmlFiles> -->
<classpathScope>test</classpathScope>
<skipTests>false</skipTests>
<!-- <testFailureIgnore>true</testFailureIgnore> -->
<testSourceDirectory>/src/test/java/testRunners</testSourceDirectory>
<useTestNG>false</useTestNG>
<rerunFailingTestsCount>2</rerunFailingTestsCount>  
</configuration>
</plugin>

亚军课

@RunWith(Cucumber.class)
@CucumberOptions(
features = "src/test/java/features",
glue= {"stepDefinitions"},  
tags= {"@licensing01"},
dryRun = false,
plugin = {"com.cucumber.listener.ExtentCucumberFormatter:TestExecutionReports/TestResults.html"
+ ",rerun:TestExecutionReports/failed_scenarios.txt"
+ ",json:target/cucumber.json"},
monochrome = true
)

public class TestRunnerBAU extends AbstractTestNGCucumberTests{
}

我希望失败的测试会自动重新运行。但是当前失败的测试不会重新运行。

1 个答案:

答案 0 :(得分:1)

按照Maven指南

  

JUnit 4.x (不支持 TestNG

支持此功能

2.21.0 起,提供者 surefire-junit47 可以重新运行由 cucumber-jvm 2.0.0及更高版本创建的方案。

>

来源: https://maven.apache.org/surefire/maven-surefire-plugin/examples/rerun-failing-tests.html

相关问题