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

KoverVerify fails on companion object #495

Closed
BulatInDrive opened this issue Oct 25, 2023 · 2 comments
Closed

KoverVerify fails on companion object #495

BulatInDrive opened this issue Oct 25, 2023 · 2 comments
Assignees
Labels
Bug Bug issue type S: untriaged Status: issue reported but unprocessed

Comments

@BulatInDrive
Copy link

Describe the bug
I have a class with a companion object. Both class and companion object have 1 function each. The validation rule is set to minValue = 20. The class function has test, but the companion object does not. When I run koverVerify, I get an error.

Errors
Rule violated: lines covered percentage for class 'tat.mukhutdinov.moduleB.b1.HelperB1$Companion' is 0.000000, but expected minimum is 20

Expected behavior
Verify should complete successfully since total class coverage is 66.7%

Reproducer

package tat.mukhutdinov.moduleB.b1

class HelperB1 {

    fun sort(a: Int, b: Int, c: Int): List<Int> =
        listOf(a, b, c).sorted()

    companion object {
        fun foo() {
            println("foo")
        }
    }
}
image
koverReport {
    defaults {
        verify {
            rule {
                entity = GroupingEntityType.CLASS

                filters {
                    includes {
                        classes("tat.mukhutdinov.moduleB.b1.HelperB1")
                    }

                }

                bound {
                    minValue = 20
                    metric = MetricType.LINE
                    aggregation = AggregationType.COVERED_PERCENTAGE
                }
            }
        }
    }
}

Environment

  • Kover Gradle Plugin version: 0.7.3
  • Gradle version: 7.3.1
  • Kotlin project type: Kotlin/Android
  • Coverage Toolset (if customized in build script): Kover
@BulatInDrive BulatInDrive added Bug Bug issue type S: untriaged Status: issue reported but unprocessed labels Oct 25, 2023
@shanshin
Copy link
Collaborator

Hi,
at the moment, Kover evaluates coverage by JVM classes, so all nested or companion classes have an individual percentage of coverage.

@shanshin
Copy link
Collaborator

Closed in favor of #498

@shanshin shanshin closed this as not planned Won't fix, can't repro, duplicate, stale Oct 27, 2023
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