Jacoco Kotlin数据类过滤吸气剂和吸气剂?

时间:2018-09-13 13:44:40

标签: kotlin code-coverage jacoco

因此,在更新到Jacoco 0.8.2之后,我的数据类代码覆盖率得到了极大的改善,因为它现在可以过滤掉大多数生成的函数(“ equals”,“ hashcode”等)。但是,它仍在寻找测试Kotlin生成的所有getter和setter。

是否缺少我想要将其过滤掉的其他设置?我知道我可以过滤掉整个类或目录,但是理想情况下,有一种方法可以过滤掉这些功能。以下是我目前对Jacoco的gradle任务。

project.jacoco {
                toolVersion = '0.8.2'
            }

            project.tasks.create(
                    name: 'jacocoTestReport',
                    type: JacocoReport,
                    dependsOn: "test${capVariant}UnitTest"
            ) {
                def buildDir = project.buildDir

                def coverageSourceDirs = [
                        "src/main/java",
                        "src/main/kotlin"
                ]

                def fileFilter = [
                        '**/R.class',
                        '**/R$*.class',
                        '**/*$ViewInjector*.*',
                        '**/*_Factory.*',
                        '**/*_MembersInjector.*',
                        '**/*$ViewBinder*.*',
                        '**/BuildConfig.*',
                        '**/Manifest*.*',
                        '**/di/**',
                        '**/*Activity*.*',
                        '**/*Fragment*.*',
                        '**/*Adapter*.*',
                        '**/*ViewHolder*.*',
                        '**/reusableComponents/**',
                        '**/App.*'
                ]

                def javaClasses = fileTree(
                        dir: "$buildDir/intermediates/classes/$folder",
                        excludes: fileFilter
                )
                def kotlinClasses = fileTree(
                        dir: "$buildDir/tmp/kotlin-classes/$variant",
                        excludes: fileFilter
                )
                KotlinGeneratedFilter = true
                group = "Reporting"
                description = "Generate Jacoco coverage reports for the ${project.name} with the " +
                        "$variant variant."
                classDirectories = files([ javaClasses ], [ kotlinClasses ])
                additionalSourceDirs = files(coverageSourceDirs)
                sourceDirectories = files(coverageSourceDirs)
                executionData = files("${project.buildDir}/jacoco/test${capVariant}UnitTest.exec")
                reports {
                    xml.enabled = true
                    html.enabled = true
                }
            }

0 个答案:

没有答案