Multi module JAVA Maven project Jacoco code coverage report setup required for sonarqube (cover Unit and Integration Test report)



Multi module JAVA Maven project Jacoco code coverage report setup for sonarqube (cover Unit and Integration Test report). Please help how to setup for pom.xml (plugins & configaration)

(Adam Gabryś) #2

It works OOTB. You only need to add jacoco-maven-plugin in the main pom.xml:


and install JaCoCo plugin on SonarQube server.


HI Adam,

Thanks for reply, i have one more [Unit test are running while build time and integration tests (IT) running on another server while running some functional test cases. I am copying that generated jacocIT.exec files to build server and i need to merge both together then need to send sonar dashboard. How can i configure this kind of situation.

(Adam Gabryś) #4

I think you have to do the following steps:

  1. generate unit tests coverage on a main server
  2. generate integration tests coverage on an other machine
  3. send coverage from the other machine to the main server
  4. merge jacoco results
  5. execute only sonar analysis, and pass the merged jacoco report: mvn sonar:sonar -Dsonar.jacoco.reportPaths=/path/to/merged/jacoco.exec

I hope it works :slight_smile:

(Sufyan Haroon) #5

Hi Adam,

Is there a way by which I can only post the coverage reports (both unit and integration tests merged) to SonarQube without running the analysis.
Actually, I am running this in a Jenkins Pipeline where the Static Code Analysis would have happened in an earlier stage and its result posted to the SonarQube server. This stage runs before integration tests are run. At a later stage in the pipeline, when all the tests have executed and I have the merged coverage report, I want to post the coverage reports only without running the analysis again. Is it possible?
Any help in this regard will be appreciated.




(Adam Gabryś) #7

According to my current knowledge - no, it is impossible.

Please don’t forget to accept the solution.