Unit tests across multi module projects

Hello,
I have multi module maven projects with unit tests to each module.
project
module A
-src
-main
-test
module B
-src
-main
-test
module C
-src
-main
-test

Modules B and C depends on module A.

The problem is some of the tests in module B contains unit tests for both module A and B.
Module A also contains unit tests for itself.
(This is for historic reasons).
So I don’t want it to behave as per module but refer to the overall code and have coverage of the project. So it will refer all the code as one module and all unit tests as tests for the whole project, but without changing the project structure.
Is is possible to change the module behavior by configuration?

Using sonarqube version 7.7
sonar-maven-plugin:3.4.0.905
jacoco 0.8.2

I tried to change the sonar.reportPath to be the same for all modules but the coverage is still per module.

Hi @navap123

If you want to merge the coverage of all your modules, you have to:

  • configure your coverage engine to produce a single report. I will assume you are using JaCoCo, that produces one report per module by default. You can see an example here where we are telling JaCoCo to append coverage of all modules in the same file in the parent module target folder.
  • configure the SonarQube scanner to pick this same coverage file for all modules. Example.

Hope that help.