Tracking Unit test and Integration test coverage separately

jacoco
sonarqube
coverage

(Prakash Dewan) #1

Must-share information:

  • which versions are you using
    SonarQube 6.7.4 LTS
  • what are you trying to achieve
    Plot Unit test and Integration test coverage captured from Jacoco separately.
  • what have you tried so far to achieve this
    this use to work fine in SonarQube 5.6, however it was not supporting multiple coverage sessions (i.e. *.exec) files for integration tests - So upgraded to SonarQube 6.7.4. Now, I found that it just merge both (it and ut exec).

(Nicolas Bontoux) #2

Hi Prakash,

The concept of Coverage has been streamlined and simplified in SonarQube v6.x. This does mean, for example, that there are no more dedicated metrics for each test type. Note that this is mentioned in the Release 6.2 Upgrade Notes (more details there).

At a high-level the idea really is to position SonarQube as a consolidator of all the possible coverage data you may wish to import (in a flexible/scalable way). That evolution also allows to track 0 coverage on files that have executable code without associated coverage data. And ultimately it lets each underlying tool reports their specific suite/results in the most suitable manner (and you should consult those reports if you want a more fine-grained view into coverage results).


(Prakash Dewan) #3

Thanks for prompt response Nicolas. So, there is no way I can plot Unit test and Integration test coverage side by side with SonarQube 6.2 onwards?


(Nicolas Bontoux) #4

Correct. In SonarQube it’s all merged into one metric.


(David Matějček) #5

So now we cannot get information about how much code is covered by unit tests and with integration tests? If the coverage by itests is too high, it is possible risk. Integration tests are obviously heavy, complicated, slow, … but on the other side give more real usage results. Having this information is useful even if it is not exact.

Can we expect some changes in this problematic? I have another problem - coverage of application modules produced by integration tests run with TestContainers and Docker is ignored by SonarQube. I can look at it only with the Eclipse editor (I can import the *.exec file and it works).

Also, even SonarQube 7.4 tells the count of Unit tests, but it is count of all JUnit tests.seznam%20rezervac%C3%AD1

… a day later, EDIT: I finally managed to merge the exec file produced by the docker run, so my “another problem” is resolved. :slight_smile:
If someone would need to help … set the relative path to the additional common exec file in project administration and it’s all, for example: ../backend-tests/target/jacoco/jacoco-docker.exec
Sonar will merge all available exec files and filter only classes from the current module.