2011-10-12 83 views
0

我想生成我的報告,所以我用maven-surefire-plugin發送測試報告,以不同的目錄。使用maven-萬無一失,插件

這是我的pom.xml:

<plugins> 
<plugin> 
<groupId>org.apache.maven.plugins</groupId> 
<artifactId>maven-surefire-plugin</artifactId> 
<version>2.10</version> 
<executions> 
<execution> 
<id>test-reports</id> 
    <phase>install</phase> 
    <configuration> 
     <tasks> 
<junitreport todir="./reports"> 
<fileset dir="./reports"> 
<include name="TEST-*.xml"/> 
</fileset> 
<report format="frames" todir="./report/html"/> 
</junitreport> 
</tasks> 
    </configuration> 
    <goals> 
     <goal>test </goal> 
    </goals> 
    </execution> 
</executions> 
</plugin> 

但是當我運行Maven的測試,我得到這個錯誤:

Tests run: 6, Failures: 2, Errors: 2, Skipped: 0 
[INFO] -------------------------------------------------------------------- 
[INFO] BUILD FAILURE 
[INFO] -------------------------------------------------------------------- 
[INFO] Total time: 10.403s 
[INFO] Finished at: Wed Oct 12 08:35:10 CEST 2011 
[INFO] Final Memory: 17M/126M 
[INFO] -------------------------------------------------------------------- 
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-  plugin:2.10:test (default-test) on project jebouquine: There are test failures. 
[ERROR] 
[ERROR] Please refer to C:\Users\Amira\workspace1\jebouquine\target\surefire-reports for the individual test results. 
[ERROR] -> [Help 1] 
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. 
[ERROR] Re-run Maven using the -X switch to enable full debug logging. 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles: 
[ERROR] [Help 1]  http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException 

當我打開C:\Users\Amira\workspace1\jebouquine\target\surefire-reports我發現repotrts但我想要他們在./reports

任何想法如何做到這一點?或者有什麼替代方案來生成我的測試報告?

回答

5

看,這裏的底線:你需要閱讀更多有關Maven的,因爲你已經寫了沒有意義的東西。你已經嘗試將ant配置元素填充到surefire插件配置中,這根本就不對。並且您試圖將其綁定到安裝階段,但是您正在運行mvn test

最後,如果你解釋你爲什麼要他們在第一時間不同的目錄......有可能是一個更好的方式來實現自己的真正目標是可能有幫助。

然而,這將解決您的問題在未來5秒左右:

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-surefire-plugin</artifactId> 
    <version>2.10</version> 
    <configuration> 
    <reportsDirectory>${project.build.directory}/reports</reportsDirectory> 
    </configuration> 
</plugin> 
+0

感謝ü但我用您選擇的代碼,但我仍然有同樣的錯誤:我應該使用maven-的JUnit報告 - 插入?? –

+0

我還以爲你想要reports',而不是'神火-reports'下'的報告。他們現在應該在正確的位置,不是嗎? –