我正在尝试按照此处所述实现 CodeCov/Jacoco:
本指南非常适用于主应用程序模块,在应用程序级 build.gradle 中使用 'com.android.application 指定。
但是,我有第二个名为 video_library 的库模块,它被指定为在其 build.gradle 上带有“com.android.library”的库。
每当我尝试为 video_library 模块运行 Jacoco 任务时,这些任务都会运行,但它无法运行我编写的任何单元测试,就好像它找不到任何测试一样(尽管这个模块有超过 50 个)
项目结构如下:
├── app
│ ├── build
│ └── src
├── build
│ └── kotlin
├── gradle
│ └── wrapper
└── library_video
├── build
├── sampledata
└── src
我以与 app 模块相同的方式实现了 jacocoTestReport:
plugins {
id 'com.android.library'
id 'kotlin-android'
id 'kotlin-kapt'
id 'org.jetbrains.dokka'
id 'maven-publish'
id 'jacoco'
}
task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest', 'createDebugCoverageReport']) {
reports {
xml.enabled = true
html.enabled = true
}
def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*']
def debugTree = fileTree(dir: "${buildDir}/intermediates/classes/debug", excludes: fileFilter)
def mainSrc = "${project.projectDir}/src/main/java"
sourceDirectories.setFrom(files([mainSrc]))
classDirectories.setFrom(files([debugTree]))
executionData.setFrom(fileTree(dir: "$buildDir", includes: [
"jacoco/testDebugUnitTest.exec",
"outputs/code-coverage/connected/*coverage.ec"
]))
}
是否需要对 library_video 模块实现进行调整才能找到测试?