Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kotlinx.kover.api.KoverTaskExtension#getExcludes does not exclude classes and functions from the report #162

Closed
yuriykulikov opened this issue Apr 12, 2022 · 4 comments
Labels
Question Support request issue type S: waiting for clarification Status: additional information required to proceed

Comments

@yuriykulikov
Copy link

Summary

Excluding packages, functions or classes using excludes, disables instrumentation for these classes, but they are still displayed in the report and therefore still reduce overall code coverage.

given

In root project:

plugins {
  id("org.jetbrains.kotlinx.kover") version "0.5.0"
}

in subproject:

tasks.test {
  extensions.configure(kotlinx.kover.api.KoverTaskExtension::class) {
    excludes =
        listOf(
            "**.xml.*",
        )
  }
}

when

./gradlew koverReport

then

Excluded packages are listed in the report with 0 coverage, thereby reducing overall code coverage.

expected

Excluded packages are completely removed from the report and do not count towards overall code coverage.

@yuriykulikov
Copy link
Author

May be related to #156, #153

@shanshin
Copy link
Collaborator

Hi,
in the current version of the API, the filter for instrumentation and the filter for reports are configuring in different places.
In your example, you excluded a class from instrumentation - in this case, coverage for such a class will always be 0 in the report.

To exclude a class from a report (for example, from an HTML report), you just need to add an exclusion rule to the report generation task:

tasks.koverHtmlReport {
    excludes = listOf("**.xml.*")
}

In the upcoming releases, the API will be redesigned and it will be enough to specify the filter only in one place.

@shanshin shanshin added the Question Support request issue type label Apr 12, 2022
@shanshin shanshin added the S: waiting for clarification Status: additional information required to proceed label May 19, 2022
@shanshin
Copy link
Collaborator

Feel free to reopen if there are additional questions.

@bitspittle
Copy link

Thanks for filing this bug. I had the same confusion and this helped me get on the right path again.

As of right now, it seems like the right way to do this is:

kover {
    filters {
        classes {
            excludes += "**.xml.*"
        }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question Support request issue type S: waiting for clarification Status: additional information required to proceed
Projects
None yet
Development

No branches or pull requests

3 participants