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

Test fixtures are included in coverage #83

Closed
markslater opened this issue Nov 30, 2021 · 5 comments
Closed

Test fixtures are included in coverage #83

markslater opened this issue Nov 30, 2021 · 5 comments

Comments

@markslater
Copy link

Kover treats test fixtures as production code, including them in coverage reports. Test fixtures should be treated as test code.

If I add the (misleadingly named) java-test-fixtures plugin, along with the kotlin and kover plugins, Gradle will look in src/testFixtures/kotlin for code "used to setup the code under test, or provide utilities aimed at facilitating the tests of a component":

plugins {
    kotlin("jvm") version "1.6.0"
    `java-test-fixtures`
    id("org.jetbrains.kotlinx.kover") version "0.4.4"
}

The testFixtures code is explicitly test code, but if I run ./gradlew koverHtmlReport, the generated report includes any code in the testFixtures directory in addition to the code in main.

I've put together a small example project illustrating the issue.

@shanshin
Copy link
Collaborator

To search for project classes, Kover uses all the source sets except test.
An API is currently being developed to exclude a source set by name, in your case it is testFixtures (see #19)

@markslater
Copy link
Author

Great.

To search for project classes, Kover uses all the source sets except test.

This doesn't sound quite right to me - Gradle defines the test fixtures as test code. Although there are circumstances under which you might want to measure the test coverage of your test fixtures (you can optionally publish test fixtures), it's counterintuitive to combine this with the coverage of the m̀ain source set by default.

@shanshin
Copy link
Collaborator

shanshin commented Jan 21, 2022

This doesn't sound quite right to me - Gradle defines the test fixtures as test code.

Kover takes a list of project classes from all available source sets (except for test). The fact that the source set is a test is determined only by the java-test-fixtures plugin, Gradle itself does not know about its purpose (class org.gradle.api.tasks.SourceSet). Therefore, there is no attribute in the Grade API by which Kover could exclude the fixtures classes.

@markslater
Copy link
Author

Fair enough.

I think the built-in Jacoco plugin only takes the main source set by default, and is configurable to add more. To me, this seems intuitive, but I accept opinions may vary.

@shanshin
Copy link
Collaborator

shanshin commented Apr 8, 2022

Duplcates #19

*filtering of sourcesets

@shanshin shanshin closed this as completed Apr 8, 2022
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

2 participants