【问题标题】:Maven Surefire does not rerun failed testng test, what's wrong with my configurations?Maven Surefire 不会重新运行失败的 testng 测试,我的配置有什么问题?
【发布时间】:2018-12-12 00:55:58
【问题描述】:

我是 surefire 插件的新手,正在尝试设置以重新运行易碎测试。

我的配置如下:

            <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.0.0-M2</version>
            <configuration>
                <suiteXmlFiles>
                    <suiteXmlFile>${suiteXmlFile}</suiteXmlFile>
                </suiteXmlFiles>
                <rerunFailingTestsCount>1</rerunFailingTestsCount>
            </configuration>
        </plugin>

而我使用的命令是:

mvn clean test -DsuiteXmlFile=testNG.xml -Dsurefire.rerunFailingTestsCount=2

我明白了:

[ERROR] Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 11.12 s <<< FAILURE! - in TestSuite

[ERROR] ieTest1(com.mycompany.testcases.Sample.independentTest)  Time elapsed: 3.839 s  <<< FAILURE!

java.lang.AssertionError: expected [true] but found [false]

但是我可以看到 /target/surefire-reports 已生成,但没有重新运行。任何人都可以帮助弄清楚为什么重播没有触发?

【问题讨论】:

  • 如果您的测试真的很不稳定,可以修复它们...这是唯一的解决方案...不要重复它们...
  • 我不拥有这些测试。我来自支持自动化运行的基础架构团队。
  • 你应该联系开发人员并让他们修复他们......
  • 检查target/surefire-reports有输出吗?
  • 是的,我收到了可靠的报告。

标签: maven testng maven-surefire-plugin


【解决方案1】:

从 3.0.0-M4 开始支持“重新运行”功能,请参阅Feature Matrix

有关更多详细信息,请参阅这些 Jiras:

Support @ParameterizedTest for JUnit 5 test reruns

Rerun Failing Tests with JUnit 5

Surefire / Failsafe rerun failed tests functionality fails with JUnit 5 if using @DisplayName

不要使用 forkCount=0。它在重要的项目中几乎没有用处。

干杯 Tibor17

【讨论】:

【解决方案2】:

根据http://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#rerunFailingTestsCount,rerunFailingTestsCount 仅适用于自 3.0.0-M4 起的 JUnit 4+ 提供程序和 JUnit 5+ 提供程序,不适用于 TestNG。

我也在调查这个问题,目前为止最完整的解释似乎在那里:https://www.toolsqa.com/selenium-webdriver/retry-failed-tests-testng/

【讨论】:

  • TestNG 在我们的计划中。
猜你喜欢
  • 2016-11-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-16
相关资源
最近更新 更多