Kotlin / kotlinx-kover

Apache License 2.0
1.37k stars 53 forks source link

A class is not included in the test coverage report if it is written in a separate file on one line. #687

Open DomainName97 opened 1 month ago

DomainName97 commented 1 month ago

Describe the bug Same test suite, but different instruction coverage measurements exist

Expected behavior Сoverage measurements should be equal

Reproducer When a class written in a separate file on one line, it is not included in test coverage. But if you write it in several lines, it will be included in the test coverage report.

Reports

Снимок экрана 2024-09-17 в 13 43 37 Снимок экрана 2024-09-17 в 13 43 15

Environment

shanshin commented 1 month ago

Hi, could you create a small reproducer project? It was not possible to reproduce this issue locally.

DomainName97 commented 1 month ago

I will try to explain. The class VerificationFailedException has a parameter(throwable) in the constructor, which is not used in the code.

Creating a class object looks like the following

catch (exception: RustoreHttpException.BadRequestException) {
            throw VerificationFailedException(exception)

Then I check the type of an object not using class parameters

is VerificationFailedException -> {
         ...
 }

In that case, the class is not included in the test coverage report if it is written in a separate file on one line. But if the class parameter is used in the code, then the single-line class will be included in test coverage

DomainName97 commented 1 month ago

Furthermore, if you write it in several lines, it will be included in the test coverage report