我是 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,但没有重新运行。任何人都可以帮助找出为什么重播没有触发?
最佳答案
根据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/
关于Maven Surefire 不会重新运行失败的 testng 测试,我的配置有什么问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53734572/