Kotlin / kotlinx-kover

Apache License 2.0
1.27k stars 47 forks source link

Inline methods from a library is not fully covered #154

Closed mustafaozhan closed 1 year ago

mustafaozhan commented 2 years ago

Hello 👋

I have recently moved my all asserts below

assertTrue { it is SomeClass }

with

assertIs<SomeClass>(it)

assertIs is an inline method in Kotlin Stdlib and covered: https://github.com/JetBrains/kotlin/blob/6a670dc5f3/libraries/kotlin.test/common/src/test/kotlin/kotlin/test/tests/BasicAssertionsTest.kt#L323-L357 But my overall coverage decreased. It seems like Kover is not recognizing this for the inline methods. It behaves like I do own this method, and there is no test written for inline methods of other libraries.

In case you want to see the PR: https://github.com/Oztechan/CCC/pull/511

shanshin commented 2 years ago

Hi, sorry for the delay, could you please indicate the names of the functions whose coverage disappeared after the changes were made? The final coverage takes into account only the function invokes of your project, the function calls of the standard library are not included in the report.

A call of this type does not affect the percentage of coverage in any way because no project functions are called inside the block.

assertTrue { it is SomeClass }
mustafaozhan commented 2 years ago

Hello @shanshin thank you for your message, meanwhile I think I put the title wrong, just updated.

So here are my reports: https://codecov.io/gh/Oztechan/CCC/compare/d7295893f5b302e5293da52a671a9fc6cc76aa56...8144e243a3fa7c305005c4c5c3b544f7b360b08d/diff

in case you are not able to see the reports, I am attaching a sample screenshot too:

Screenshot 2022-04-11 at 09 21 29

As you can see, all the new lines are partially covered and overall class coverage is decreased.

shanshin commented 2 years ago

@mustafaozhan, do you use only codecov to analyze the percentage of project coverage?

mustafaozhan commented 2 years ago

@shanshin I use also Codacy, but it is not showing detailed like codecov does, according to Codacy only %74 percent of my total changes are covered, assuming that in the PR I only replaced

assertTrue { it is SomeClass }

with

assertIs<SomeClass>(it)

It sounds like Codacy is also decreasing my Coverage.

But I think it is normal, at the end I use same xml report generated via Kover and upload it to both platform.

shanshin commented 2 years ago

Usually evaluating coverage for tests from commonTest source set not make sense. In the future releases, this will be excluded from the report (same as a test source set).

It was not possible to reproduce the error locally

assertIs<Any>(it)

the line is completely covered.

Perhaps the problem is in displaying coverage in codecov, an example of an XML report would be useful.

mustafaozhan commented 2 years ago

Hey @shanshin here is my coverage report, I couldn't upload here.

https://gist.githubusercontent.com/mustafaozhan/153a54519478ba4cc57e09d7878f549b/raw/67784289c98d408b2c9f6ba58652b12444299ea7/report.xml

shanshin commented 2 years ago

Thanks!

Relates to https://youtrack.jetbrains.com/issue/IDEA-292007

zuevmaxim commented 1 year ago

Fixed in agent version 1.0.674

shanshin commented 1 year ago

Fixed in 0.6.0, feel free to reopen if the problem reproduced again.