I am using maven-jacoco-plugin for generating the test coverage. Version used is 0.8.7.
When running the mvn test
command, it's generating the report in exec format.
<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>
When I tried adding in configuration tag under using XML, it's giving an error as
Unable to parse configuration of mojo org.jacoco:jacoco-maven-plugin:0.8.8:report-aggregate for parameter formats: Cannot assign configuration entry 'formats' with value 'XML' of type java.lang.String to property of type java.util.List -> [Help 1]
Can anyone please suggest how to move forward on this?
You must add a format node:
<formats>
<format>XML</format>
</formats>
On GitHub you can find examples. Like this: https://github.com/jacoco/jacoco/blob/master/jacoco-maven-plugin.test/it/it-report-select-formats/pom.xml
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.