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

annotatedBy doesn't exclude classes from coverage #555

Closed
nuhkoca opened this issue Feb 29, 2024 · 2 comments
Closed

annotatedBy doesn't exclude classes from coverage #555

nuhkoca opened this issue Feb 29, 2024 · 2 comments
Assignees
Labels
Bug Bug issue type S: waiting for clarification Status: additional information required to proceed

Comments

@nuhkoca
Copy link
Contributor

nuhkoca commented Feb 29, 2024

Describe the bug
Hello, I created a custom annotation but classes annotated with it are still included in code coverage.

Expected behavior
Classes/functions annotated by KoverIgnore should be excluded from coverage.

Reproducer

internal val annotationExclusions = listOf(
    "<project_path>.common.utils.KoverIgnore",
    "androidx.compose.runtime.Composable",
    "androidx.compose.ui.tooling.preview.Preview",
    "<project_path>.snapshot.PreviewTest",
    "*Generated",
)

configure<KoverReportExtension> {
        filters {
            excludes {
                classes(coverageExclusions)
                packages(packageExclusions)
                annotatedBy(annotationExclusions.joinToString())
            }
        }
    }

Reports
If applicable, report files or screenshots.

Screenshot 2024-02-29 at 16 00 50

Environment

  • Kover Gradle Plugin version: 0.7.6
  • Gradle version: 8.2.2
  • Kotlin project type: Kotlin/Android
  • Coverage Toolset: Kover
@nuhkoca nuhkoca added Bug Bug issue type S: untriaged Status: issue reported but unprocessed labels Feb 29, 2024
@shanshin
Copy link
Collaborator

Hi,
your configuration uses joining all annotations into one String annotationExclusions.joinToString(), however, only one annotation should be written in each string.

you should write like this

annotatedBy("annotation1", "annotation2")

or if you have a list with annotations, like this

annotatedBy(*annotationExclusions.toTypedArray())

@shanshin shanshin added S: waiting for clarification Status: additional information required to proceed and removed S: untriaged Status: issue reported but unprocessed labels Feb 29, 2024
@nuhkoca
Copy link
Contributor Author

nuhkoca commented Feb 29, 2024

Thank you, it's fixed!

@nuhkoca nuhkoca closed this as completed Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Bug issue type S: waiting for clarification Status: additional information required to proceed
Projects
None yet
Development

No branches or pull requests

2 participants