mercredi 25 novembre 2015

Android Studio 1.4 Code Coverage

I'm having some trouble to get code coverage on my project. My unit and UI tests are placed on the "androidTest" folder. Tests run smoothly but when I try to get code coverage (both running with coverage or ./gradlew createDebugCoverageReport from CLI) I get different type of errors.

Here's my build.gradle.

apply plugin: 'com.android.application'
apply plugin: 'jacoco'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        debug {
            testCoverageEnabled = true
        }

        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    jacoco {
        version "0.7.1.201405082137"
    }
}

dependencies {
    compile 'junit:junit:4.12'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.1'
    compile 'com.google.code.gson:gson:2.2.4'
    compile 'com.android.support:design:22.2.1'
    compile 'com.android.support:recyclerview-v7:22.2.+'
    compile 'com.android.support:cardview-v7:22.0.+'
    compile 'com.mcxiaoke.volley:library:1.0.19'
    compile 'com.github.bmarrdev:android-DecoView-charting:v0.9.3'
    compile 'com.github.PhilJay:MPAndroidChart:v2.1.5'
    compile 'com.wefika:horizontal-picker:1.1.0'
    compile 'info.hoang8f:android-segmented:1.0.6'
    compile 'com.google.guava:guava:18.0'

    testCompile 'com.android.support.test:testing-support-lib:0.1'
    testCompile 'com.android.support:support-annotations:22.0.1'
    testCompile 'com.android.support.test:runner:0.4.1'
    testCompile 'com.android.support.test:rules:0.4.1'
    testCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
    testCompile 'org.hamcrest:hamcrest-library:1.3'

    androidTestCompile 'com.android.support:support-annotations:22.0.1'
    androidTestCompile 'com.android.support.test:runner:0.4.1'
    androidTestCompile 'com.android.support.test:rules:0.4.1'
    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
    androidTestCompile 'org.hamcrest:hamcrest-library:1.3'

    androidTestCompile ('com.android.support.test.espresso:espresso-contrib:2.0') {
        exclude group: 'com.android.support', module: 'appcompat'
        exclude group: 'com.android.support', module: 'support-v4'
        exclude module: 'recyclerview-v7'
    }
}

Please let me know how to set code coverage for both InstrumentationTestCase and ActivityInstrumentationTestCase2 placed on "androidTest" folder.

Thanks!

Aucun commentaire:

Enregistrer un commentaire