为我的 Android 应用程序运行 jacoco 覆盖率报告会导致:
[ant:jacocoReport] Execution data for class de/abc/def/MyApplication does not match.
-> 覆盖率报告 0%
android 应用程序使用 Hilt 并需要一个 Application 类
@HiltAndroidApp
class MyApplication : Application()
这很可能是相关的,因为
有什么解决办法吗? 我考虑过以某种方式删除任何标签之前的注释,但我相信 Hilt 开发人员在测试过程中一定遇到过这种情况
(AGP 7.2.1、Gradle 7.4.2、jacoco 0.8.10)
在最新版本的 JaCoCo 8.7 及更高版本中,您可以为 Android 项目中的 androidTestCoverage 和 unitTestCoverage 生成报告。这些报告是在报告文件夹中单独创建的,您可以在其中找到每种覆盖类型的不同 reports.xml 文件。
声纳变化
// Define multiple paths in a list
def xmlReportPaths = ['/path/to/first/report.xml','/path/to/second/report.xml']
// Convert the list to a comma-separated string
def xmlReportPathString = xmlReportPaths.join(',')
// 在脚本或配置中设置属性 // 例如,在 Gradle 构建脚本中:
sonarqube {
properties {
property 'sonar.xmlReportPaths', xmlReportPathString
}
}
更改后运行声纳命令。 gradlew 声纳库
现在您可以看到所有覆盖的文件。 它会起作用的。