tse*_*tse 6 unit-testing jacoco kotlin test-coverage
Jacoco显示Kotlin数据类的覆盖率为0%。如何配置它以测量覆盖率或完全忽略数据类?
如果您已将数据类放在特定包下或特定文件中,则可以将它们从classDirectories. 在下面的示例中,我将数据类放在下面**/model/**:
task kotlinJacocoTestReport(type: JacocoReport, dependsOn: 'test') {
reports {
html.enabled = true
html.destination = "${buildDir}/reports/jacoco"
}
sourceDirectories = files(["${project.projectDir}/src/main/kotlin"])
classDirectories = fileTree(dir: "${buildDir}/classes/kotlin/main", excludes: ['**/model/**'])
executionData = files("${buildDir}/jacoco/test.exec")
}
Run Code Online (Sandbox Code Playgroud)
我一直在寻找针对相同测试覆盖率问题的解决方案,该解决方案具有针对数据模型类的自动生成的代码,偶然发现以下问题:
Kotlin + JaCoCo:调整编译器以跳过生成的代码
解决方案:将 JaCoCo插件更新为0.8.2,您的问题已解决。
JaCoCo已在0.8.2版本中解决了此问题,请阅读changelog-
| 归档时间: |
|
| 查看次数: |
3602 次 |
| 最近记录: |