Missing coverage in Android kotlin project

Hello,
we have problems with the code coverage displayed in Sonar Cloud for an Android project written in kotlin.

In short:
Jacoco report (XML file) is generated, but somehow it’s not uploaded to Sonar Cloud or is uploaded incorrectly - Sonar Cloud still shows 0% of the code coverage.
We use Azure DevOps pipelines as our CI.

The configuration:

  • in our project we use custom jacoco gradle task for building jacoco reports,
  • an output of unit tests in form of an *.exec file is generated as expected,
  • the jacoco report in form of XML file is generated correctly and the coverage is not zero (see below),
<counter type="INSTRUCTION" missed="68078" covered="12314"/>
<counter type="BRANCH" missed="3198" covered="306"/>
<counter type="LINE" missed="11687" covered="1260"/>
<counter type="COMPLEXITY" missed="5022" covered="812"/>
<counter type="METHOD" missed="3354" covered="702"/>
<counter type="CLASS" missed="834" covered="339"/>
  • in our Azure DevOps build pipeline we have added the following tasks:

Prepare Analysis Configuration
Publish Quality Gate Result

  • “Prepare Analysis Configuration” contains some advanced properties. One of them is a path to the jacoco report

sonar.coverage.jacoco.xmlReportPaths=**/reports/test* Coverage/*.xml

We are not sure if the XML file is correctly uploaded correctly - is there a possibility to preview the uploaded XML file on Sonar Cloud?

Do you have any hint what should we check? We’re running out of ideas…

Best regards,
Michał

Hi @mwolny and welcome to the community !

Which scanner are you using for the analysis ?

Thanks.

Hi Mickaël,
thanks for your answer.

I finally was able to solve the issue.
It turned out the problem was related to the Azure Pipeline task “Prepare Analysis Configuration”.

I had to replace the path to an XML file from the one containing asterisk signs

sonar.coverage.jacoco.xmlReportPaths=**/reports/test* Coverage/*.xml

to the full path

sonar.coverage.jacoco.xmlReportPaths=build/reports/fullNameOfMyTestCoverageDir/fullNameOfCoverageReportFile.xml

Now sonar cloud displays correct values of the code coverage.

1 Like