Unable to get code coverage from UI test cases for android (kotlin) project in sonar cloud


There are UI test cases for android project in app/src folder but the number of lines are analyzed and showing as uncovered with 0.0% coverage on the folder.

Any suggestion on the existing issue would be helpful.


Hey there.

Do you actually run the tests as a part of your build, before the SonarCloud analysis?

Hi @Colin ,

Yes we execute the tests before the sonar cloud analysis task.

Below are the steps we are using in the pipeline:

  1. Prepare sonar analysis
  2. gradlew test
  3. publish code coverage (for the pipeline)
  4. Sonar run code analysis
  5. publish quality gate results

Please let me know if you need additional information.



Have you configured the JaCoCo report to export XML reports?

What do the logs say about the import of code coverage?

Hi @Colin ,

I notice the jacoco configuration is configured using jacoco.gradle file in repository and i don’t see any config in the build.gradle, could you please confirm is this mandatory to use this in the build.gradle accordingly will request developers to make the changes.

Waiting on your response.


It’s not strict that the configuration needs to be in a build.gradle file, but you must be outputting a JaCoCo XML report (and if not to the default location, then that location should be defined using sonar.coverage.jacoco.xmlReportPaths as documented).

Yes we are getting the reports to the default path but the UI test cases aren’t calculating over there.

So some coverage is being reported to SonarCloud, but not all? It sounds like an issue with generating the coverage reports to include coverage from the UI test cases, not an issue with SonarCloud reading the report.

Yes we are only seeing the code coverage from projfolder/main/java folder not form the other folder where the UI test cases exists.