maven工程使用jacoco-maven-plugin插件,無法生成覆蓋率測試報告問題
當(dāng)我們在maven工程中引入maven-surefire-plugin插件執(zhí)行單元測試代碼后,突然發(fā)現(xiàn)在集成jacoco-maven-plugin插件生成測試覆蓋率報告時,因為插件參數(shù)配置問題,發(fā)現(xiàn)無法生成測試報告了。
解決方案
此時,
1、我們在jacoco-maven-plugin插件中定于一個屬性<propertyName>surefireArgLine</propertyName>
<execution>
<id>pre-unit-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<propertyName>surefireArgLine</propertyName>
</configuration>
</execution>
2、在 maven-surefire-plugin插件中使用這個參數(shù)即可生成測試報告<argLine>${surefireArgLine}</argLine>
文章來源:http://www.zghlxwxcb.cn/news/detail-540805.html
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>false</skip>
<testFailureIgnore>true</testFailureIgnore>
<argLine>${surefireArgLine}</argLine>
</configuration>
</plugin>
3、maven-surefire-plugin,jacoco-maven-plugin顯示無覆蓋。
maven-surefire-plugin在多模塊項目中指定兩次時表現(xiàn)不可預(yù)測。
父模塊的pom中引入了該插件,而子模塊pom也在構(gòu)建部分中有它。因此,它似乎正在運行測試,但子模塊中的覆蓋率始終為0。
修復(fù)是從子模塊pom中刪除maven-surefire-plugin,并且只在父pom的build部分中有它。
問題得到了解決。
上述問題只是解決方案之一,具體問題具體分析。文章來源地址http://www.zghlxwxcb.cn/news/detail-540805.html
到了這里,關(guān)于maven工程使用jacoco-maven-plugin插件,無法生成覆蓋率測試報告問題的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!