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:-
You can also configure the code coverage ratio in the plugin by using the rules tag like this:-
You can either write the covered ratio as 10% or 0.10 .
Sometimes we get a build error like following
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.