【发布时间】:2021-02-09 02:02:21
【问题描述】:
我没有使用 TestNG。我想使用 Maven 自动重新运行失败的测试场景。
当我触发 mvn 时,应该运行测试并为所有失败的场景创建 rerun.txt。我可以在运行时创建 rerun.txt,但不能自动运行失败的场景。
testrunner.java
@CucumberOptions(
features = "src/main/features/",
plugin = {"pretty", "html:target/cucumber-report", "json:target/cucumber-
report/report.json", "rerun:target/rerun/rerun.txt"},
tags = {"@test"},
pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>**/*testrunner*.java</include>
</includes>
</configuration>
</plugin>
另外,我知道我可以创建另一个测试运行器以重新运行并手动运行它。当我这样做并将其添加到 pom.xml 时。 testReRunner 有时会运行而不会在 rerun.txt 文件中创建失败的测试用例。
【问题讨论】:
-
JUnit 和 TestNG 就是为此而构建的……你为什么不使用它们呢?更不用说测试中的断言了。
-
@JeffC 测试用例太多,无法在脚本中添加任何逻辑。它必须经过框架级别。另外,我们没有使用 TestNG。
-
您是否尝试将
<rerunFailingTestsCount>1</rerunFailingTestsCount>添加到surefire 插件的<configuration>中?它适用于 JUnit,因此它有可能适用于 Cucumber -
@Fenio 感谢您的帮助。我能够使用您的方法重新运行失败的测试用例。我还有一个问题。这对报告有何影响?
-
@AjayGC 据我记得,你会在测试报告中得到这两个结果
标签: selenium testing automation cucumber gherkin