我目前正在使用createDebugAndroidTestCoverageReport来运行我的android检测测试并生成覆盖率报告。我遇到的唯一问题是有从Realm和Databinding生成的包,这些类也包含在我的覆盖报告中。如何配置jacoco以排除这些包?
答案 0 :(得分:0)
test {
jacoco {
append = false
destinationFile = file("$buildDir/jacoco/jacocoTest.exec")
classDumpFile = file("$buildDir/jacoco/classpathdumps")
excludes = []
}
}
Click here for more details on official Jacoco Gradle Plugin
答案 1 :(得分:0)
在定义 debugTree
时,您可以添加要排除的fileFilters。
task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest', 'createDebugCoverageReport']) {
reports {
xml.enabled = true
html.enabled = true
}
def fileFilter = ['**/package/**']
def debugTree = fileTree(dir: "${buildDir}/intermediates/classes/debug", excludes: fileFilter)
}