1. 程式人生 > >maven專案打包:maven-surefire-plugin:2.18.1:test (default-test) on project agent_api: There are test fail

maven專案打包:maven-surefire-plugin:2.18.1:test (default-test) on project agent_api: There are test fail

在專案打包中遇到的問題,
問題 :Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test (default-test) on project agent_api: There are test failures.

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test (default-test) on project agent_api: There are test failures.
[ERROR]
[ERROR] Please refer to
E:\gitRep\agentapi\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

解決思路
1 在出現這個錯誤的時候我的第一印象是專案中包沒有下全吧,可能是由於jar包的關係導致的不成功,我用的開發工具是idea,開啟maven project看了一下沒有發現jar包存在問題,
2 不是jar包的問題難道是我專案分支的問題, 我用的打包命令是mvn install。但是這個簡單的專案是用springboot沒有區分test,dev,prod分支啊,配置檔案中區分的打那個分支的包,檢查了一下,也不是分支的問題
3 看下上面的報的問題吧,也許他會給我靈感
這裡寫圖片描述


報錯的問題中有幾個關鍵點test測試,還給了一個tager路徑,我在專案中找到這個tager路徑並開啟一看全是我的單元測試。看到這裡的時候我想難道是我的單元測試中有問題麼,如果單元測試中有問題上面的列印日誌會報錯的啊,我就往上翻翻看,果然
這裡寫圖片描述
這是我單元測試中69行報錯了null所以導致了打包失敗,到這裡錯誤就找到了,單元測試中如果有錯誤問題打包時會引起Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test (default-test) on project agent_api: There are test failures.

結果演示
這裡寫圖片描述