I love SonarQube for its potential. The reality of it is somewhat different, you need a byzantine series of configurations to make it play nicely with Jenkins, Maven and Jacoco. It gets more difficult when you have a multi module build – i.e. a parent pom with modules set up in it.
I’m not going to claim any ownership for the decent how-to on this. The amazing David Valeri in https://davidvaleri.wordpress.com/2013/09/06/tracking-integration-test-coverage-with-maven-and-sonarqube/ has nailed this issue. Here is a quick summary of what you need to look out for:
- You probably run your integration tests using the failsafe runner rather than surefire
- If multiple projects have different bits of integration test, you’ll need to configure the jacoco plugin so that it shares a single jacoco.exec file across all modules
- If one of your projects is an integration test project (our case) you just need to know where jacoco will write its output
- In the parent pom.xml you will create a property for sonar to tell it where to find the integration test coverage report
- Paths, especially once jenkins gets involved, can be complex
If you get it right, it works a treat.
See the linked post for details. Kudos to David!