我目前正在我的团队构建的 Android 代码库中设置 Jacoco。我在 Android 方面没有太多经验,但我之前已经在 Spring Boot 代码库中设置了 Jacoco,以便我可以跟踪 Sonarqube 中的测试覆盖率。但我在 Android 代码库中遇到了困难。
\n所以目录布局看起来像这样
\nMyApp/\n\xe2\x94\x9c\xe2\x94\x80 app/\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80 build/\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80 src/\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80 build.gradle.kts\n\xe2\x94\x9c\xe2\x94\x80 buildSrc/\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80 build.gradle.kts\n\xe2\x94\x9c\xe2\x94\x80 modules/\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80 module1/\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80 src/\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80 build.gradle.kts\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80 module2/\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80 src/\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80 build.gradle.kts\n\xe2\x94\x9c\xe2\x94\x80 build.gradle.kts\n\xe2\x94\x9c\xe2\x94\x80 gradle.properties\n\xe2\x94\x9c\xe2\x94\x80 gradlew\n\xe2\x94\x9c\xe2\x94\x80 settings.gradle.kts\nRun Code Online (Sandbox Code Playgroud)\n我尝试添加jacoco到MyApp/build.gradle.kts.
plugins {\n id(Dependencies.Plugins.androidApplication) version Dependencies.Versions.androidAppplication apply false\n id(Dependencies.Plugins.androidLibrary) version Dependencies.Versions.androidLibrary apply false\n id(Dependencies.Plugins.hilt) version Dependencies.Versions.hilt apply false\n id(Dependencies.Plugins.openApi) version Dependencies.Versions.openApi\n id(Dependencies.Plugins.kotlinAndroid) version Dependencies.Versions.kotlinAndroid apply …Run Code Online (Sandbox Code Playgroud) 我有一个具有 4 个变体的 Android 应用程序,并且有一个运行以下命令的 Bitrise 实例:
./gradlew "testDevADebugUnitTestCoverage" "testDevBDebugUnitTest" "testDevCDebugUnitTest" "testDevCDebugUnitTest" "--continue" "-PjacocoEnabled=true"
在开发分支中以确保一切正常。
我最近使用 Android Studio 中的 AGP 升级助手升级到 Gradle 8 和 AGP 8.0.1,当我在本地或在 Bitrise 中运行上述命令时,我遇到了几个错误,如下所示。
我不得不说,Gradle 错误适用于许多不同类型的任务:KotlinCompile、、、、。JacocoReportMergeSourceSetFoldersProcessTestManifest
Some problems were found with the configuration of task ':domain:compileDevADebugKotlin' (type 'KotlinCompile').
- Gradle detected a problem with the following location: '/Users/MyUser/Developer/yapp/domain/build/tmp/kotlin-classes/devADebug'.
Reason: Task ':domain:testDevBDebugUnitTestCoverage' uses this output of task ':domain:compileDevADebugKotlin' without declaring an explicit or implicit dependency. This can lead to incorrect results being …Run Code Online (Sandbox Code Playgroud)