[英]JaCoCo Maven plugin generate report in XML format
我正在使用 maven-jacoco-plugin 生成測試覆蓋率。 使用的版本是 0.8.7。
運行mvn test
命令時,它會生成 exec 格式的報告。
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco-maven-plugin.version}</version>
<configuration>
<formats>XML</formats>
</configuration>
<executions>
<!-- Prepares the property pointing to the JaCoCo runtime agent which is passed as VM argument when Maven
the Surefire plugin is executed. -->
<execution>
<id>jacoco-initialize-unit-test</id>
<goals>
<goal>prepare-agent</goal>
<goal>report</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/../target/site/jacoco-aggregate</outputDirectory>
<!--<destFile>${project.build.directory}/../../target/coverage-reports/jacoco-ut.exec</destFile>-->
<append>true</append>
<propertyName>jacoco.agent.argLine</propertyName>
</configuration>
</execution>
<execution>
<id>jacoco-initialize-integration-test</id>
<phase>pre-integration-test</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${project.build.directory}/../../target/coverage-reports/jacoco-it.exec</destFile>
<append>true</append>
<propertyName>jacoco.agent.argLine</propertyName>
</configuration>
</execution>
<execution>
<id>jacoco-merge</id>
<phase>post-integration-test</phase>
<goals>
<goal>merge</goal>
</goals>
<configuration>
<fileSets>
<fileset>
<directory>${project.build.directory}/../../target/coverage-reports/</directory>
<includes>
<include>*.exec</include>
</includes>
</fileset>
</fileSets>
<destFile>${project.build.directory}/../../target/coverage-reports/jacoco.exec</destFile>
</configuration>
</execution>
<!-- Ensures that the code coverage report for integration tests is created after all tests have been
run. -->
<execution>
<id>jacoco-report</id>
<phase>verify</phase>
<goals>
<goal>report-aggregate</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/../target/site/jacoco-aggregate</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
當我嘗試在使用 XML 下添加配置標簽時,它給出了一個錯誤
無法解析 mojo org.jacoco:jacoco-maven-plugin:0.8.8:report-aggregate 的配置參數格式:無法將 java.lang.String 類型的值為“XML”的配置條目“格式”分配給類型的屬性java.util.List -> [幫助 1]
任何人都可以建議如何繼續前進嗎?
您必須添加一個格式節點:
<formats>
<format>XML</format>
</formats>
在 GitHub 上,您可以找到示例。 像這樣: https ://github.com/jacoco/jacoco/blob/master/jacoco-maven-plugin.test/it/it-report-select-formats/pom.xml
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.