相关文章推荐
逆袭的菠萝  ·  python调用powershell - ...·  2 月前    · 
讲道义的甘蔗  ·  mysql ...·  6 月前    · 
好帅的苦咖啡  ·  makefile windows vs ...·  1 年前    · 
愉快的钱包  ·  jupyterNotebook ...·  1 年前    · 
disabled = false binaryReportFile.set(file("$buildDir/custom/debug-report.bin")) // includes = ['com.example.*'] excludes = [ "com.makeappssimple.abhimanyu.financemanager.android.navigation.di.NavigationManagerModule"

我希望这段代码能排除 com.makeappssimple.abhimanyu.financemanager.android.navigation.di.NavigationManagerModule 文件,但它没有工作。 我也试过用通配符命名。

Kover setup,

plugins {
    id "com.android.application"
    id "kotlin-android"
    id "kotlin-kapt"
    id "dagger.hilt.android.plugin"
    id "com.google.gms.google-services"
    id "org.jetbrains.kotlinx.kover" version "0.5.0"
// Kover
kover {
    disabled = false                        // true to disable instrumentation of all test tasks in all projects
    coverageEngine.set(kotlinx.kover.api.CoverageEngine.INTELLIJ) // change instrumentation agent and reporter
    intellijEngineVersion.set('1.0.656')    // change version of IntelliJ agent and reporter
    jacocoEngineVersion.set('0.8.7')        // change version of JaCoCo agent and reporter
    generateReportOnCheck = true            // false to do not execute `koverMergedReport` task before `check` task
    disabledProjects = []                   // ["project-name"] or [":project-name"] to disable coverage for project with path `:project-name` (`:` for the root project)
    instrumentAndroidPackage = false        // true to instrument packages `android.*` and `com.android.*`
    runAllTestsForProjectTask = false       // true to run all tests in all projects if `koverHtmlReport`, `koverXmlReport`, `koverReport`, `koverVerify` or `check` tasks executed on some project

P.S: 我也提出了同样的问题here

1 个评论
rob
看起来你在提供的链接中关闭了你的问题github.com/Kotlin/kotlinx-kover/issues/177.如果这充分解决了你的问题,你可以自我回答这个SO问题,并包括任何可能对未来网站访客有帮助的细节。
android
kotlin
code-coverage
kover
Abhimanyu
Abhimanyu
发布于 2022-05-11
2 个回答
Carmen
Carmen
发布于 2022-06-29
已采纳
0 人赞同

你也可以尝试在kover插件中添加一个过滤器,像这样version 0.6.0

kover {
    instrumentation {
        excludeTasks.add("testReleaseUnitTest")
    filters {
        classes {
            excludes += listOf(
                "dagger.hilt.internal.aggregatedroot.codegen.*",
                "hilt_aggregated_deps.*",
                "*ComposableSingletons*",
                "*_HiltModules*",
                "*Hilt_*",
                "*BuildConfig",
                ".*_Factory.*",
    
Abhimanyu
Abhimanyu
发布于 2022-06-29
0 人赞同

感谢山心's comment, I understood the issue.

使用此代码修正了单元测试覆盖率报告的排除列表

tasks.koverHtmlReport {
    excludes = [
            // Hilt
            "*.di.*",
            "dagger.hilt.**",
            "hilt_aggregated_deps.*",
            "<package_name>.*.*_Factory",
            // Room
            // MyRoomDatabase_AutoMigration_*_Impl, *Dao_Impl
            "<package_name>.*.*_Impl*",
            // BuildConfig
            "<package_name>.BuildConfig",
            // Moshi - Json Adapter