Android createDebugCoverageReport 不再显示覆盖率
Android createDebugCoverageReport doesn't show coverage anymore
运行 ./gradlew createDebugCoverageReport
和 Android gradle 插件 v1.3.1 曾经给我一个包含代码覆盖率的 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
}
}
}
我在 运行 我的覆盖率测试后注意到类似的行为。当我打开 index.html 时,它只是告诉我哪些测试通过了,哪些测试失败了。它没有给我以前看到的覆盖率。
这是我看到的图像。如您所见,找不到百分比数字。
然后我发现我找错文件夹了!以上截图来自:
build/reports/androidTests/connected/index.html
您可以查看覆盖率的位置是:
build/reports/coverage/debug/index.html
根据您提供的信息,我不确定您是否犯了和我一样的错误,看错了地方。我想我会 post 我的答案,因为它可能会帮助像我一样迷路的人。
运行 ./gradlew createDebugCoverageReport
和 Android gradle 插件 v1.3.1 曾经给我一个包含代码覆盖率的 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
}
}
}
我在 运行 我的覆盖率测试后注意到类似的行为。当我打开 index.html 时,它只是告诉我哪些测试通过了,哪些测试失败了。它没有给我以前看到的覆盖率。
这是我看到的图像。如您所见,找不到百分比数字。
然后我发现我找错文件夹了!以上截图来自: build/reports/androidTests/connected/index.html
您可以查看覆盖率的位置是:
build/reports/coverage/debug/index.html
根据您提供的信息,我不确定您是否犯了和我一样的错误,看错了地方。我想我会 post 我的答案,因为它可能会帮助像我一样迷路的人。