Kover exclude: classes, packages and generated code
The filters that work in Kover 0.9.11, and why shop/dto/** and ShopApplication match nothing.

Kover filters take class names with dots, not file paths: shop.dto.*, not
shop/dto/**. A Kotlin file of top-level functions compiles to a class named
after the file plus Kt, so exclude shop.ShopApplicationKt.
Exclude patterns at a glance
| To exclude | Write in kover { reports { filters { excludes { … } } } } |
|---|---|
| A package | packages("shop.dto") |
| Classes by name | classes("shop.dto.*") |
| A file of top-level functions | classes("shop.ShopApplicationKt") |
| Classes or functions with an annotation | annotatedBy("*Generated") |
* matches any characters and ? one. The same filters apply to
koverVerify, so the report and the rule agree.
We ran every setup here with Kover 0.9.11, Kotlin 2.4.21 and Gradle 9.7.1 on
JDK 21. The project has five classes: Pricing and Receipt have tests; a
DTO package, a generated package and the main file have none. Without
filters, the report has 8 of 16 lines.
Exclude packages and classes
kover {
reports {
filters {
excludes {
packages("shop.dto", "shop.generated")
classes("shop.ShopApplicationKt")
}
}
}
}
packages("shop.dto", "shop.generated") alone left three classes, 7 of 11
lines. classes("shop.dto.*", "shop.ShopApplicationKt") left three as well,
8 of 11: Pricing, Receipt and the generated MoneyKt.

Exclude generated code with an annotation
annotation class Generated
@Generated
fun debugDump(value: Any): String {
val text = value.toString()
return text
}kover { reports { filters { excludes { annotatedBy("*Generated") } } } }
Receipt went from 2 of 4 lines to 2 of 2. annotatedBy("shop.Generated")
did the same. Kover reads the annotation from the compiled class: with
@Retention(AnnotationRetention.SOURCE) the function stayed, at 2 of 4 lines.
Kotlin’s default retention, RUNTIME, works.
Why your Kover exclude isn’t working
| What we tried | What happened |
|---|---|
classes("shop/dto/**", "shop/ShopApplication*.class") | Nothing excluded: Kover matches class names, not paths |
classes("shop.ShopApplication") for ShopApplication.kt | The main class stayed: it is shop.ShopApplicationKt |
koverVerify with minBound(80) and no filters | Failed at 50% |
| The same rule with the filters above | Failed at 77.8%: the filters apply to verify too |

If you came from JaCoCo, this is the opposite convention: JaCoCo excludes
take shop/dto/**, Kover shop.dto.*. See JaCoCo exclude.
What Supercov adds
supercov -- ./gradlew test
supercov runs latest gaps
Supercov runs the same Gradle build and records which test covered each line, with branches and MC/DC, without Kover in the build. On this project it showed that no test tried a large order from a non-member. See Kotlin code coverage for Kover, JaCoCo and Supercov side by side.
More coverage guides
- Jest coverageThreshold: global, per-folder and per-file
- JaCoCo aggregate report for multi-module Maven and Gradle builds
- pytest ignore directory: --ignore, norecursedirs and collect_ignore
- Merge coverage reports from shards: Vitest, Jest and coverage.py
- Statement vs branch coverage, with decision, line and path coverage
- JaCoCo report not generated: the causes in Maven and Gradle
- sonar.coverage.exclusions: why SonarQube ignores your JaCoCo excludes
- istanbul ignore next vs c8 ignore next: every hint, measured
- Go test coverage exclude: files, packages and mocks
- Jest coverage exclude: files, folders and lines
- pytest coverage exclude: omit files, folders and lines
- Vitest coverage exclude: files, folders and lines
- JaCoCo exclude in Maven and Gradle: packages, classes and generated code