I have a question about code coverage:
I have a large Android app with multiple modules as in:
project
- app->src->main->java->com->example->MyImportantClass
- module1->src->main->java
- module2->src->main->java
- module3->src->main->java
I’ve configured Sonar to run against each module independently, as in:
./gradlew :app:sonarqube
./gradlew :module1:sonarqube
./gradlew :module2:sonarqube
I do this by looping over each module name and for each module the JUnit tests and JaCoCo coverage report is generated for that module (sonarqube task depends on jacocoTestReport and test). This method allows me to break down the project on a module-by-module basis rather than as a monolith project.
My question:
In module1
I use Dagger to inject an instance of class MyImportantClass
that lives in module app
. MyImportantClass
in module app
has JUnit tests covering the class so coverage is fine in app
module.
However, in my scenario when I run sonarqube
task for module1
the JUnit tests in module app
will not be run. Running sonarqube
for module1
will run test
, jacocoTestReport
and sonarqube
only for module1
.
My question becomes: would Sonar consider coverage of MyImportantClass
to be “not covered”? Or would coverage measure only the use of this class?