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

How can we exclude generated files? #30

Closed
vivart opened this issue Oct 22, 2021 · 10 comments
Closed

How can we exclude generated files? #30

vivart opened this issue Oct 22, 2021 · 10 comments

Comments

@vivart
Copy link

vivart commented Oct 22, 2021

tasks.withType<Test> {
    extensions.configure(kotlinx.kover.api.KoverTaskExtension::class) {
        generateXml = false
        generateHtml = true
        coverageEngine = kotlinx.kover.api.CoverageEngine.INTELLIJ
        includes = listOf("com\\.example\\..*")
        excludes = listOf("dagger\\.hilt\\..*", "com\\.example\\.settings\\.*FragmentDirections\\.*")
    }
}

I am able to exclude hilt package but FragmentDirections files are still showing in the report.

@shanshin
Copy link
Collaborator

Hi! At the moment, the API of the plugin does not imply the exclusion of specific classes from the report. See #17
includes and excludes controls the instrumentation of the specified classes but not the report.

@shanshin
Copy link
Collaborator

Duplicate #17

@zhimbura
Copy link

zhimbura commented Nov 9, 2021

Hi! At the moment, the API of the plugin does not imply the exclusion of specific classes from the report. See #17 includes and excludes controls the instrumentation of the specified classes but not the report.

Why exclude don't work?

I am have next exclude template

image

but in output I am have

image

@zhimbura
Copy link

@shanshin Can you see what I'm doing wrong?

@vivart
Copy link
Author

vivart commented Nov 10, 2021

This works for me

tasks.withType<Test> {
    extensions.configure(kotlinx.kover.api.KoverTaskExtension::class) {
        isEnabled = true
        binaryReportFile.set(file("$buildDir/custom/result.bin"))
        includes = listOf("com\\.example\\..*")
        excludes = listOf(
            "dagger\\.hilt\\..*",
            "com\\.example\\.todo\\.databinding\\..*",
            "com\\.example\\.todo\\.di\\..*",
            "com\\.example\\.todo\\.ui\\.display\\..*",
            "com\\.example\\.todo\\.ui\\.edit\\..*",
            "com\\.example\\.settings\\..*",
        )
    }
}

@shanshin
Copy link
Collaborator

shanshin commented Nov 10, 2021

Hi! At the moment, the API of the plugin does not imply the exclusion of specific classes from the report. See #17 includes and excludes controls the instrumentation of the specified classes but not the report.

Why exclude don't work?

I am have next exclude template

image

but in output I am have

image

Perhaps you have another test task in your project in which these classes are not excluded?
What is the content of the file build/tmp/koverHtmlReport/intellijreport.args after the build ?
The first few lines will list reports for completed test tasks

And what do you use as an coverage engine, JaCoCo or IntelliJ?

@SimonedeGijt
Copy link

SimonedeGijt commented Nov 17, 2021

Hey guys, I have a similar issue. When I exclude some packages from kover it is indeed not taken into account in the percentages Class%, Block% and Line%. But because it is still part of the report, the overall coverage drops. This leads to an even more negative result than when I wouldn't exclude it. I use Kotlin 1.6.0 with Gradle 7.3. My configuration:

kover {
  isEnabled = true
  coverageEngine.set(kotlinx.kover.api.CoverageEngine.INTELLIJ)
  intellijEngineVersion.set(intellijVersion)
  generateReportOnCheck.set(true) 
}

tasks.test {
  extensions.configure(kotlinx.kover.api.KoverTaskExtension::class) {
    isEnabled = true
    binaryReportFile.set(file("$buildDir/reports/kover/result.bin"))
    includes = listOf("org\\.example\\.something\\.blabla\\..*")
    excludes = listOf(
      "org\\.example\\.something\\.blabla\\.controller\\..*"
    )
  }
}

@shanshin
Copy link
Collaborator

shanshin commented Nov 29, 2021

@SimonedeGijt, please check in version 0.4.4.

@shanshin
Copy link
Collaborator

shanshin commented Nov 29, 2021

@Tihon-Ustinov, please, if the problem is reproduced in version 0.4.4, create a new one issue with a detailed description.

@purposebakery
Copy link

Just for that random soul coming across the same issue above version 0.4.4: I'm currently on version 0.6.0 and this doesn't work for me when I set the exclusions on module level. If I enable koverMerged and run the merged task and set the exclusions on project level this works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants