[英]Upgrade to AGP 4.2.0 ,unable to generate Jacoco code coverage report
Jacoco code coverage was working fine till I upgrade Android Gradle Plugin to 4.2.0 , no only app module code coverage getting generated, for modules it is not working. Jacoco代码覆盖率工作正常,直到我将Android Gradle 插件升级到4.2.0 ,不仅生成了应用程序模块代码覆盖率,对于模块它不起作用。 Any Idea how to fix this issue.
任何想法如何解决这个问题。
I was having the same problem after upgrading to 4.2.1.升级到 4.2.1 后我遇到了同样的问题。
It looks like the Jacoco execution data file for non-instrumented unit tests has been renamed to 'jacoco.exec', and moved to the module's top-level directory.看起来非仪表化单元测试的 Jacoco 执行数据文件已重命名为“jacoco.exec”,并移至模块的顶级目录。
In the configuration of my JacocoReport gradle task, this works for me:在我的 JacocoReport gradle 任务的配置中,这对我有用:
executionData.from = "${project.projectDir}/jacoco.exec"
NOTE: The execution data file for instrumented tests has not been renamed or moved.注意:仪器测试的执行数据文件没有被重命名或移动。
Based on amazing Richard answer , if you previously had this setup (which is pretty standard for unit and instrumented tests with Jacoco in Android)基于惊人的 Richard回答,如果您以前有此设置(这对于在 Android 中使用 Jacoco 进行的单元和仪器测试非常标准)
executionData.from = fileTree(dir: project.buildDir, includes: [
"jacoco/${testTaskName}.exec",
"outputs/code_coverage/${variantName}AndroidTest/connected/**/*.ec"
])
You can switch to this equivalent for AGP 4.2.X您可以切换到 AGP 4.2.X 的等效版本
executionData.from = files([
"$project.projectDir/jacoco.exec",
fileTree(dir: project.buildDir, includes: [
"outputs/code_coverage/${variantName}AndroidTest/connected/**/*.ec"
])
])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.