Kotlin / kotlinx-kover

Apache License 2.0
1.28k stars 48 forks source link

Class with constants #451

Closed clickjamper closed 2 months ago

clickjamper commented 10 months ago

Why do you need to write tests for classes which contains only constants like

internal object TestObject { const val TEST_CONST = "test_const" }

shanshin commented 9 months ago

Hi, Kover notifies only that an object has been declared in the code that is not explicitly used anywhere.

Unfortunately, when compiling, the constant is not stored in the class, so Kover cannot determine exactly how this object will be used - independently or as a scope for grouping constants.

In this case, it is possible to exclude such classes from the report by name or using an annotation.

zuevmaxim commented 6 months ago

@shanshin Fixed in agent version 1.0.741

shanshin commented 6 months ago

Fixed in Kover 0.7.5

BulatInDrive commented 6 months ago

I updated Kover to 0.7.5, but it still shows that an object containing only constants has no tests.

image
shanshin commented 6 months ago

@BulatInDrive, thanks for the report! The problem is reproduced for string constants

hanrw commented 3 months ago

Same issue shows that an interface containing companion object

Snipaste_2024-03-16_16-45-09
shanshin commented 2 months ago

Reproduced for companion objects

shanshin commented 2 months ago

Closed in favour of https://github.com/Kotlin/kotlinx-kover/issues/583