POM

How to fix a drop of code coverage with a multi module Maven project

Posted on by  
Jacob van Lingen

Adding code coverage to SonarQube is quite easy for any Maven project nowadays. Just add the jacoco-maven-plugin dependency to your pom.xml, add the prepare-agent execution task, and you are good to go. Even for multiple modules this works out of the box. But time goes on and your application grows as well. You start moving code to other modules, and somehow SonarQube no longer seems to pick up the covered code. What the heck is going on?

The answer is shamefully simple. You did not write proper unit tests, but component tests. JaCoCo assumes at default every module has its own set of tests. So, as soon as your test covers multiple modules, only the 'current' module is counted as covered code.

Continue reading →

shadow-left