Distinguish unit vs integration coverage in quality gate metrics and per line view

Hello,

We send two coverage reports to SonarQube in one analysis, one from our unit tests and one from our integration tests, and SonarQube merges them into a single Coverage number. We would like to know whether SonarQube can tell the two apart: in the quality gate metrics, in the file view when looking at a covered line, or through a plugin.

What we are trying to achieve

Our Python service runs two test suites in CI, unit tests and integration tests. Each suite produces its own coverage XML report, and we pass both to one analysis using:

sonar.python.coverage.reportPaths=coverage.xml,coverage-integration.xml

SonarQube merges them into a single Coverage metric. That merged number is what we want for the quality gate, but we would also like to see how much each suite contributes.

Questions

  1. Quality gate metrics by coverage type. Is there a way to identify the coverage type (unit or integration) in the quality gate metrics? We would like conditions such as “unit coverage on new code >= X%” and “integration coverage on new code >= Y%”, instead of one merged number.

  2. Per line attribution in the UI. When viewing a file, can SonarQube show which report covered a given line (unit, integration, or both)?

  3. Plugin. Is there a plugin, from the Marketplace or elsewhere, that adds coverage by report metrics or per line report attribution?

Any pointers to documentation, a setting, or a recommended workaround would be very helpful.

Thanks in advance,

Eman

Hey @Eman_Harri, this is not supported, SonarQube aggregates coverage reports and doesn’t retain where did each coverage value come from. I think this is not the first time that a user shows interest in such a feature. I’m going to flag this for a product manager to look into.

Hello @andres,

We would really appreciate it if you could take this request into consideration for a future enhancement. Being able to distinguish unit test coverage from integration test coverage, both in the metrics/Quality Gate and at the per-line level, would be very valuable for all.

Thank you for your time

Regards,

Eman

It would be nice if SonarQube supported a flags scheme similar to what Datadog Code Coverage supports: https://docs.datadoghq.com/code_coverage/flags/
This way you can use flags by language, by type (integration / unit / e2e / etc) or whatever you like.