Trying to get code coverage for testFixtures

We run Sonarqube Enterprise Edition v10.0 from TeamCity builds of gradle-based project. I have a project which includes several subprojects that have testFixtures sources. I updated the Jacoco configuration to include the testFixtures code. Code coverage for the testFixtures classes is added to the code coverage report for the whole project, both in the html report and in the xml file build/reports/jacoco/codeCoverageReport/codeCoverageReport.xml. The project sets sonar.coverage.jacoco.xmlReportPaths to that file.

Unfortunately, when Sonarqube is run, it fails to report on code coverage for any of the testFixture classes, even though the covarage information for these classes appears in the xml file. It only reports coverage for main and test sources. Is anything else needed to make it include testFixtures code in the code coverage report?

1 Like

Hello @caveycrd, thank you for reporting this interesting issue.

Can you provide me with the following information?

  • How did you update the Jacoco configuration to include the testFixtures code?
  • What configuration for the sonarqube plugin are you using? Can you share it?
  • Can you provide the Jacoco xml report that is generated? I’m looking for the section reporting the coverage of testFxitures sources

The code coverage in SonarQube is essentially the same as in the Jacoco xml report. SonarQube uses sonar-jacoco to parse the Jacoco xml report and to collect the relevant data to display. In theory, if the testFixtures sources are present in the Jacoco xml report then these should be available in SonarQube as well. I’ll be able to help you more once I’ll have more details.

Cheers