Android createDebugCoverageReport不再显示覆盖范围

时间:2016-01-21 21:28:37

标签: android android-gradle jacoco

使用Android gradle插件v1.3.1运行./gradlew createDebugCoverageReport用于给我一个包含代码覆盖百分比的html文件。

现在使用gradle 1.5.0甚至2.0.0-alpha7,报告更加有限,并且没有显示覆盖百分比。

如何重新启用覆盖率报告?

这是我的gradle配置:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.0.0-alpha7'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "some.id"
        minSdkVersion 10
        targetSdkVersion 23

        testApplicationId applicationId + ".test"
        testInstrumentationRunner "android.test.InstrumentationTestRunner"
    }

    buildTypes {
        release {
            // ...
        }
        debug {
            debuggable true
            testCoverageEnabled true
        }
    }
}

1 个答案:

答案 0 :(得分:2)

我在使用coverage进行测试后发现了类似的行为。当我打开index.html时,它只显示了哪些测试通过,哪些测试失败了。它没有给我我过去常常看到的覆盖率。

这是我所看到的图像。如您所见,没有找到百分比数字。 enter image description here

然后我意识到我在查找错误的文件夹!以上屏幕截图来自: 的建立/报告/ androidTests /连接/ index.html中

您可以去查看覆盖百分比的地方是: 的建立/报告/覆盖/调试/ index.html中 enter image description here

根据您提供的信息,我不确定您是否通过查找错误的地方犯了同样的错误。我想我会发布我的答案,因为它可能会帮助那些迷路的人,就像我迷路一样。