JaCoCo for Java code coverage: Utilities

Under projects/build/plugins, add the following XML:

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.2</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
And under projects, add this XML:

<reporting>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<reportSets>
<reportSet>
<reports>
<!-- select non-aggregate reports -->
<report>report</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>

Now all you need to do is run the command mvn test jacoco:report
You can find this report in the target/site/jacoco directory in your project.

Refer Jacoco site https://www.eclemma.org/jacoco/ for more details.

Comments

Popular posts from this blog

Understanding and Avoiding Race Conditions in Java

The Interplay of Money and Risk

For Java