簡體   English   中英

Jenkins未在構建狀態中顯示所有Junit報告

[英]Jenkins not showing all the Junit reports in the status of the build

我有一個Maven構建,其中包含多個項目,而這些項目又包含許多子Maven模塊。 在測試階段,每個項目將執行其測試,並以編程方式生成junit測試報告,並將其放在/ target / surefire-reports /中的相應模塊target文件夾中。 在Jenkins的構建狀態頁面中構建成功后,我可以將測試結果顯示為圖形。 但是問題是Jenkins並沒有將所有生成的junit xml都接受,而只需要一部分。 我在整個構建中總共有850個測試用例,但在圖形和測試結果中僅顯示449個。 是什么原因造成的。

生成junit報告沒有問題,所有測試用例都可以生成報告,但是Jenkins無法識別所有報告。 對於Jenkins,測試案例的數量因每個構建而異,而無需添加或刪除任何測試文件。

僅供參考:我正在手動生成junit報告。 要將其通知給Jenkins,我啟用了maven sure fire插件並將報告添加到target的surefire-reports文件夾中。 我創建了maven build項目,而不是自由樣式項目

我有什么想念的嗎?

我也遇到了這個問題,這是我的想法: http : //javamemento.blogspot.no/2016/02/sonar-jacoco-maven-multi-module.html

  1. 問題是您需要將結果串聯到一個報告文件中。

因此,您的pom應該具有以下內容:

<build>
    <plugins>
        <plugin>
  <groupId>org.jacoco</groupId>
  <artifactId>jacoco-maven-plugin</artifactId>
  <version>0.7.5.201505241946</version>
  <executions>
   <execution>
    <id>agent-for-ut</id>
    <goals>
     <goal>prepare-agent</goal>
    </goals>
    <configuration>
     <destFile>${sonar.jacoco.reportPath}</destFile>
     <append>true</append>
    </configuration>
   </execution>
   <execution>
    <id>agent-for-it</id>
    <goals>
     <goal>prepare-agent-integration</goal>
    </goals>
    <configuration>
     <destFile>${sonar.jacoco.itReportPath}</destFile>
     <append>true</append>
    </configuration>
   </execution>
  </executions>
    </plugin>
 </plugins>
</build>

這里的關鍵字是

<append>true</append>

現在,您的所有數據將存儲在1個報告文件中。

  1. 確保僅在父pom中調用了maven-surefire-plugin。 如果您也將其包含在子pom中,則結果將被父pom覆蓋。 此處有更多怪癖: http : //javamemento.blogspot.no/2016/06/sonar-maven-surefire-plugin-quirks.html

  2. 最后,請確保您正確使用了junit和void方法。 測試該方法或surefire的副作用將表現出奇怪的效果。 http://junit.org/junit4/faq.html#atests_4

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM