我想重新運行一個測試,我知道會失敗,因爲我試圖測試Surefire參數以重新運行失敗的測試。 我試圖與這兩個命令如預期Surefire重新運行失敗的測試不起作用
-Dsurefire.rerunFailingTestsCount=2 -Dtest=TestThatFails test
和
-Dsurefire.rerunFailingTestsCount=2 -Dtest=TestThatFails surefire:test
這裏都沒有工作運行Maven是的pom.xml
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-api</artifactId>
<version>2.19.1</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
我期待那部分失敗後,Surefire會重新開始測試,但Maven ju st拋出這個錯誤,我知道如何解決,但我想重新運行測試。
Results :
Tests in error:
testA(selenium.services.TestThatWillFail): Element is not currently visible and so may not be interacted with(..)
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 55.060 s
[INFO] Finished at: 2016-11-24T12:58:02+01:00
[INFO] Final Memory: 18M/173M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project eskn_selenium: There are test failures.
oooooh現在我明白了! 我認爲將它作爲依賴添加將會完成這項工作,但它必須添加爲插件。我正要問,如果你沒有注意到它已經在pom.xml中定義好了,哈哈。 謝謝! –