Integrate jacoco with maven

Jacoco logo

Integrate jacoco with maven


JaCoCo is a free Java code coverage library distributed under the Eclipse Public License and it is very simple to add to all types of build including ANT and Maven, and it is also very simple to add to Java containers or a standalone JVM.

Configure Jacoco with Maven

Add these properties tag to pom.xml

Add this plugins to pom.xml

Add a test method



run the application

To run the examples execute the following command.


The results are published in /target/site/jacoco.
jacoco demo
We can drill through a more detailed view for each Java class:
application java

Report Analysis

JaCoCo reports help to visually analyze code coverage by using diamonds colors for branches and background colors for lines:
Red diamond means that no branches have been exercised during the test phase.
Yellow diamond shows that the code is partially covered – some branches have not been exercised.
Green diamond means that all branches have been exercised during the test.

Source code

Avatar for Ayman Ben Amor

Author: Ayman Ben Amor

No Comments

Post a Comment