I was unable to get code coverage to work on any of my Android projects.
To simplify things, I created a new project (selected empty asset). Added a new utility class for the project in src / main / java.
Then I created a unit test for it in src / androidTest / java.
Updated gradle file to include coverage.
apply plugin: 'com.android.application' android { compileSdkVersion 21 buildToolsVersion "21.1.2" defaultConfig { applicationId "com.example.michaelkrussel.coverageapp" minSdkVersion 15 targetSdkVersion 21 versionCode 1 versionName "1.0" } jacoco { version "0.7.1.201405082137" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } debug { testCoverageEnabled true } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:21.0.3' }
I ran tests and then used. / gradlew createDebugCoverageReport. unit test shows that the test I created passed, but the coverage report reports zero coverage.
I assume that I either missed something in the gradle file or did not complete the correct gradle task, but I canβt understand what.
source share