Why coverage tool JaCoCo reports 100% coverage?

341 Views Asked by At

I added to my project JaCoCo by editing app level build.gradle:

plugins{
    ...
    id 'jacoco'
}

jacoco {
   toolVersion = "0.8.7"
}

buildTypes {

    debug {
        testCoverageEnabled = true
    }
}

android {
   //...
}

dependencies{
  ...
}

configurations.all{
resolutionStrategy {
    eachDependency { details ->
        if ('org.jacoco' == details.requested.group) {
            details.useVersion "0.8.7"
        }
    }
   }
}

I really dont have any tests in my project, so I was expecting a very low coverage rate.

But running gradlew createDebugCoverageReport resulted in 100% coverage? I was expecting 5% or lower, since I haven't wrote any tests now. Whats wrong there?

1

There are 1 best solutions below

0
On

There is no easy answer for the given gradle output. However, you can check your Html reports in the build directory of your project. You will see the report with details. 4-5 months ago, a new version of AGP(Android Gradle Plugin) was released. It contains radical changes for the testing and Jacoco. Your tests(even you have no test) might be under the effect of these changes. The solution you are looking for depends on your project setup as well. If your projects are multi-module ones, most probably, you need to configure your gradle task to create your Jacoco report. The current Jacoco task(createDebugCoverageReport) can miss the class you expect to see in your result.