How to show coverage from connected Android Tests?

I am not able to see coverage from Android Tests in my project. I can see coverage only from unit Tests. The unit tests are running using:

gradle test

which generates reports under the path: build/reports/coverage/unitTest/debug/report.xml

The Android tests are running using:

gradle connectedAndroidTest 

which generates reports under the path: build/reports/androidTests/connected/index.html

For the unit tests this is the property that sends coverage data to Sonarqube:

property "sonar.coverage.jacoco.xmlReportPaths", "build/reports/coverage/unitTest/debug/report.xml, build/reports/coverage/unitTest/release/report.xml"'

And it is placed within build.gradle of my project. Then, coverage data are exported using:

gradle sonar

So, my question is: Can I use the build/reports/androidTests/connected/index.html report to export the coverage in Sonarqube?


Have you tried it? Is the Android test report in a format supported by SonarQube?


I tried it and this is the errors I received:

Coverage report '/build/reports/androidTests/connected/index.html' could not be read/imported. Error: {}

[854]java.lang.IllegalStateException: Failed to parse JaCoCo XML report: /build/reports/androidTests/connected/index.html


What do you make of that error?

It seems like my 2nd question is relevant here:


I don’t know how to export an xml report from connected android tests so as to use it for property “sonar.coverage.jacoco.xmlReportPaths”. is there a way to do this?


Sorry, but that’s a bit out of scope for us.


ok, thanks