User Tools

Site Tools


android:jacoco

Android Jacoco

Reference:

http://stackoverflow.com/questions/23795595/how-do-i-get-a-jacoco-coverage-report-using-android-gradle-plugin-0-10-0-or-high

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 0.6.2.201302030002 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 :

robolectric

Android Unit and Integration testing

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