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

Wrong code coverage percentage when we have Preview function in our class #736

Open
ItSNeverLate opened this issue Feb 27, 2025 · 4 comments
Assignees
Labels
Bug Bug issue type S: untriaged Status: issue reported but unprocessed

Comments

@ItSNeverLate
Copy link

Describe the bug
I can not exclue my functions which were annotated by @Preview (androidx.compose.desktop.ui.tooling.preview.Preview) in my KMP project.

@Preview
@composable
@KoverIgnore
private fun Preview() {
AppTheme {

.........

kover {
reports {
verify {
rule {
minBound(80) //80% minimum coverage
}
}
filters {
excludes {
// Entire Points
classes("MainKt") // Desktop
classes("*.MainActivity") // Android

            // Generated Classes and Resources
            classes("*.generated.*")

            // Dependency Injection
            classes("*.di.*")

            // Compose Related (UI)
             classes("*ComposableSingletons*")
            annotatedBy(
                "androidx.compose.desktop.ui.tooling.preview.Preview",
                "KoverIgnore"
            )
        }
    }
}

}

Image

Environment

  • Kover Gradle Plugin version: 0.9.1
  • Gradle version: 8.10.2
  • Kotlin project type: Multiplatform
  • Coverage Toolset: Kover
@ItSNeverLate ItSNeverLate added Bug Bug issue type S: untriaged Status: issue reported but unprocessed labels Feb 27, 2025
@ItSNeverLate ItSNeverLate changed the title Excluding function which annotated bt @Previrw Excluding function which annotated by @Previrw from code coverage Feb 27, 2025
@shanshin
Copy link
Collaborator

Hi, please provide the list of classes above Preview function

@ItSNeverLate ItSNeverLate changed the title Excluding function which annotated by @Previrw from code coverage Wrong code coverage percentage when we have Preview function in our class Feb 27, 2025
@ItSNeverLate
Copy link
Author

sorry: my problem is i have a class with two functions. and preview function is ignored and it is not listed in the class functions anymore. but the class code coverage is still 50%

Image

@ItSNeverLate
Copy link
Author

ItSNeverLate commented Feb 27, 2025

I am using this to be able to see my compose preview in android studio

@OptIn(ExperimentalMultiplatform::class)
@OptionalExpectation
@target(AnnotationTarget.FUNCTION)
expect annotation class Preview()

@ItSNeverLate
Copy link
Author

without
annotatedBy( "androidx.compose.desktop.ui.tooling.preview.Preview",
I could see preview function in the report is listed.

It means that kover ignores my function based on my configuration. But why it is counting that in class function count? (the result is 50%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Bug issue type S: untriaged Status: issue reported but unprocessed
Projects
None yet
Development

No branches or pull requests

2 participants