User Tools

Site Tools


Android Jacoco


Over the hundreds of times searching the answer to get a coverage report, I finally found a exact answer what I want.

From the this blog post, I found that gradlew createDebugCoverageReport creates the jacoco coverage report.

Also, from the gradle plugin source code, the plugin uses jacoco by default. (therefore, jacoco version definition is not required if you are going to use default version)

In summary, the ESSENTIAL steps to get a jacoco coverage report with Android gradle plugin are :

Android gradle plugin version 0.10.0 or higher (typically in your project's build.gradle)
add testCoverageEnabled true on the build type you want (i.e. debug)
run $ gradlew createDebugCoverageReport or gradlew connectedCheck to get a jacoco coverage report.
You can find your coverage report at the build/reports/coverage/[BUILD_TYPE]. (i.e. build/reports/coverage/debug for debug build)

Tip :

Since you can only get a coverage report with the emulator and device with root permission, you'll get following error after running a command on the normal(non-rooted) device :


Android Unit and Integration testing

/var/www/dokuwiki/wiki/data/pages/android/jacoco.txt · Last modified: 2016/05/05 13:07 by