【问题标题】:Rerun Failed test Cases in Cucumber Automatically using Maven Command使用 Maven 命令在 Cucumber 中自动重新运行失败的测试用例
【发布时间】: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。
  • 您是否尝试将&lt;rerunFailingTestsCount&gt;1&lt;/rerunFailingTestsCount&gt; 添加到surefire 插件的&lt;configuration&gt; 中?它适用于 JUnit,因此它有可能适用于 Cucumber
  • @Fenio 感谢您的帮助。我能够使用您的方法重新运行失败的测试用例。我还有一个问题。这对报告有何影响?
  • @AjayGC 据我记得,你会在测试报告中得到这两个结果

标签: selenium testing automation cucumber gherkin


【解决方案1】:

maven-surefire-plugin 具有重新运行失败测试的内置选项。

只需在surefire插件的&lt;configuration&gt;中添加&lt;rerunFailingTestsCount&gt;1&lt;/rerunFailingTestsCount&gt;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-11-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多