我有一個項目,測試分爲單元和集成階段。我有它運行buildbot和問題是,即使在測試失敗maven返回代碼是0,所以buildbot構建是成功的。在失敗的測試中,Maven + Surefire返回代碼爲0
這是MVN集成測試的結果:
Results :
Tests in error:
Info about failed tests
Tests run: 5, Failures: 0, Errors: 5, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 minute 19 seconds
[INFO] Finished at: Tue Feb 12 09:43:53 UTC 2013
[INFO] Final Memory: 36M/97M
[INFO] ------------------------------------------------------------------------
$ echo $?
0
結果爲MVN安裝是沒有建立成功的部分相同 結果:
Tests in error:
Info about failed tests
Tests run: 5, Failures: 0, Errors: 5, Skipped: 0
$ echo $?
0
神火配置是這樣的:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.13</version>
<configuration>
<printSummary>true</printSummary>
<excludedGroups>com.testlib.IntegrationTest</excludedGroups>
</configuration>
<executions>
<execution>
<id>unit-tests</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<excludedGroups>com.testlib.IntegrationTest</excludedGroups>
</configuration>
</execution>
<execution>
<id>integration-tests</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<includes>
<groups>com.testlib.IntegrationTest</groups>
</includes>
</configuration>
</execution>
</executions>
</plugin>
我讀過關於maven re的其他線程轉向代碼,但理論上相關的錯誤應該在我的Maven版本中修復(Apache Maven 2.2.1(rdebian-8))
有什麼方法可以改變這種行爲嗎?
更新: 作爲建議我試着與神火:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.13</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.13</version>
</dependency>
</dependencies>
<configuration>
<groups>com.testlib.IntegrationTest</groups>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<includes>
<include>**/*.class</include>
</includes>
</configuration>
</execution>
</executions>
我需要的神火,JUnit來避免初始化錯誤。
不,我沒有testFailureIgnore這個,我會嘗試故障安全 – hithwen 2013-02-12 10:48:32
啊...在我身邊的誤解,因爲你使用的集成測試需要單獨配置,就像我在最後一段中寫的那樣。 – khmarbaise 2013-02-12 11:18:39
我嘗試了故障安全,並且仍然得到0 retcode – hithwen 2013-02-12 12:41:41