我正尝试完善我的项目代码覆盖率,并希望排除任何View
类(因为它们无法进行测试),但包括任何ViewModel
类... 但是我似乎无法让通配符过滤器合作,要么全部包括,要么全部排除!
def excludedPatterns = [
//... other stuff
'**/*Fragment*.*',
'**/*Activity*.*',
'**/*Adapter*.*',
'**/*View*.*', // <-- this line is excluding classes ending w/ ViewModel
'**/*ViewState*.*',
'**/*ViewHolder*.*',
]
task codeCoverageReport(type: JacocoReport, dependsOn: 'testDebugUnitTest') {
group = "Reporting"
description = "Generate Jacoco coverage reports after running tests."
reports {
html.enabled true
}
def debugTree = fileTree(
dir: "$project.buildDir/tmp/kotlin-classes/debug",
excludes: excludedPatterns
)
classDirectories.from = files([debugTree])
def mainSrc = "$project.projectDir/src/main/java"
sourceDirectories.from = files([mainSrc])
executionData.from = fileTree(dir: project.buildDir, includes: [
'jacoco/testDebugUnitTest.exec',
'outputs/code-coverage/connected/*coverage.ec'
])
}
我尝试了几种不同的
**/*View*.*
的变化形式,包括**/*View.*
等……有什么我忽略的东西吗?
classDirectories.from = files([debugTree]).filter({file -> file.name.contains('ViewModel')})
- jesses.co.tt