我一直在使用Jacoco插件来获取我的android项目的代码覆盖率。当前正在使用此命令执行测试,
gradlew test jacocoTestReport
它仅运行robolectric和UI测试。我想运行单元测试和robolectric测试。 以下是Jacoco在build.gradle中创建的任务,
task jacocoTestReport(type: JacocoReport, dependsOn: ['test', 'createDebugCoverageReport']) {
reports {
xml.enabled = true
html.enabled = true
}
def fileFilter = [ '**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*' ]
def debugTree = fileTree(dir: "$project.buildDir/tmp/kotlin-classes/debug", excludes: fileFilter)
def mainSrc = "$project.projectDir/src/main/java"
sourceDirectories = files([mainSrc])
classDirectories = files([debugTree])
executionData = fileTree(dir: project.buildDir, includes: [
'jacoco/test.exec', 'outputs/code-coverage/connected/*coverage.ec'
])
}
有什么方法可以使用Jacoco实现单元测试和机器人测试的代码覆盖率。如果您对此有任何想法,请帮助