4

I am having issues with calculating code coverage on Android, gradle 2.14.1 with Java 8.

I've added testCoverageEnabled to my apps build.gradle:

apply plugin: 'jacoco'

android {
    debug {
        testCoverageEnabled true
    }
}

I can execute Jacoco with ./gradlew createDebugCoverageReport.

I get my coverage report (both html & .exec) but the coverage is always 0 percent. Anyone has encountered this and solved it?

Elias
  • 472
  • 3
  • 17
  • I am facing same problem raised a question about the same http://stackoverflow.com/questions/42451660/android-jacoco-coverage-shows-0-with-gradle-however-there-are-95-tests-coverin/42457455#42457455 – Guna Feb 25 '17 at 16:58
  • 1
    In my case it was device specific problem. I was running it on Samsung Tab4 and coverage was showing as 0%. When I ran the same on Emulator and on a different device (Asus Zenpad) then it shows correct coverage report – Guna Feb 27 '17 at 05:16
  • Hmm I want to calculate it for unit tests. – Elias Feb 27 '17 at 06:35
  • Did you try this? It worked for me with Unit tests as well https://medium.com/@rafael_toledo/setting-up-an-unified-coverage-report-in-android-with-jacoco-robolectric-and-espresso-ffe239aaf3fa#.sbd6apm4i – Guna Feb 27 '17 at 07:07

0 Answers0