我想使用jacoco maven plugin
來檢查構建過程中使用'check'
目標的最低代碼覆蓋率。如何使用jacoco檢查多模塊maven項目的最小代碼覆蓋率?
對於單模塊項目一切正常。 但是對於多模塊,我想檢查所有模塊的代碼覆蓋率的平均水平,但check
目標分別檢查每個模塊。
例如,模塊1具有70%的代碼覆蓋的,模塊2具有100%代碼覆蓋,在平均從兩個模塊代碼覆蓋所有的行是85%。 我試圖將所有項目的代碼覆蓋率設置爲80%,但因爲第一個模塊而失敗。
從POM:
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.6.201602180812</version>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>default-report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>default-check</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<rule>
<element>BUNDLE</element>
<limits>
<limit>
<counter>COMPLEXITY</counter>
<value>COVEREDRATIO</value>
<minimum>0.80</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
謝謝,我通過Jacoco插件爲Jenkins實現了這種方法 –