Maven Surefire 不会重新运行失败的 testng 测试,我的配置有什么问题吗?

问题描述 投票:0回答:3

我是 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,但没有重新运行。任何人都可以帮忙找出为什么重播没有触发?

maven testng maven-surefire-plugin
3个回答
3
投票

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

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


2
投票

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

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

支持 @ParameterizedTest 进行 JUnit 5 测试重新运行

使用 JUnit 5 重新运行失败的测试

如果使用 @DisplayName,Surefire / Failsafe 重新运行失败的测试功能在 JUnit 5 中会失败

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

干杯 蒂博尔17


0
投票
使用 maven-surefire-plugin 版本 2.x.x 时,使用 Junit5 重新运行 Surefire 插件的参数将不起作用。需要将maven-surefire-plugin版本升级到3.0.0-M4。

我在项目的 POM 属性中添加了以下版本声明,它解决了问题。

<maven-surefire-plugin.version>3.0.0-M4</maven-surefire-plugin.version>
    
© www.soinside.com 2019 - 2024. All rights reserved.