我曾经使用Robotium编写Android测试,并使用Emma检索覆盖率。
最近我改用了Espresso测试,我在检索Instrumentation测试的覆盖率时遇到了麻烦。我只能检索使用Robolectric的单元测试的覆盖率。我目前正在使用gradle和Jacoco来做到这一点。我找到的帮助我走到这一步的最好的教程是:https://blog.gouline.net/2015/06/23/code-coverage-on-android-with-jacoco/
是否有可能检索到使用Android工具的Espresso测试的覆盖率?
发布于 2015-11-03 05:17:50
android gradle插件有一个内置的功能。
只需在build.gradle文件中将testCoverageEnabled参数设置为true:
android {
buildTypes {
debug {
testCoverageEnabled = true
}
}
}然后使用:
./gradlew connectedCheck或
./gradlew createDebugCoverageReport它将在模块的目录中生成一个测试覆盖率报告:
/build/outputs/reports/coverage/debug/只需打开index.html
示例:

https://stackoverflow.com/questions/33393871
复制相似问题