How to fix build error related to Jacoco Test Coverage

Code coverage is a software metric used to measure how many lines of code is executed during automated tests.

Jacoco is a code coverage report generator for Java Projects. You need to add the maven plugin for jacoco and get the code coverage reports.

Jacoco Plugin dependency in pom.xml:-

Jacoco Plugin Dependency

You can also configure the code coverage ratio in the plugin by using the rules tag like this:-

Configuration and rule tag

You can either write the covered ratio as 10% or 0.10 .

Sometimes we get a build error like following 

Jacoco Build Error

To fix this issue simply add more test cases in the module which is showing the build failure.

For instance in the above stack trace the module (gcmms-api-client) is showing coverage ratio is 0.09, but expected minimum is 0.10 so simply add more test cases in this module and build the project again.The issue will be resolved.

Leave a comment

Your email address will not be published. Required fields are marked *