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

Same test suite, but different instruction coverage measurements exist #685

Open
hqsz opened this issue Sep 10, 2024 · 5 comments
Open

Same test suite, but different instruction coverage measurements exist #685

hqsz opened this issue Sep 10, 2024 · 5 comments
Assignees
Labels
Bug Bug issue type Kover Coverage Tool S: confirmed Status: bug is reproduced or present

Comments

@hqsz
Copy link
Contributor

hqsz commented Sep 10, 2024

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

Expected behavior
coverage measurements should be equal

Reproducer

  1. clone https://github.com/hqsz/kover-coverage-bug-240910
  2. execute koverHtmlReport with oneline : result is in build-with-oneline folder
  3. execute koverHtmlReport with multiline : result ins in build-with-multiline folder

Reports
With same test suite, but difference instruction coverage

image

Environment

  • Kover Gradle Plugin version: 0.8.3
  • Gradle version: 8.6
  • Kotlin project type: Kotlin/JVM
  • Coverage Toolset (if customized in build script): Kover
@hqsz hqsz added Bug Bug issue type S: untriaged Status: issue reported but unprocessed labels Sep 10, 2024
@hqsz
Copy link
Contributor Author

hqsz commented Sep 10, 2024

In fact, before reporting this bug, I encountered another similar bug. Due to the company's security issues, I cannot attach entire code. So I tried to reproduce it, but failed.

The first bug discovered was as follows :


Describe the bug

  • Unexecuted instruction coverage is filled

Expected behavior

  • Unexecuted instruction must not be filled

Reports

  • Wrong behavior
val nullableVal: Something?

when (someEnum) {
  A -> { // test suite execute all branch and all instruction and it is all green(covered), also if i remove certain branch it changes to red properly
    if (nullableVal != null) {
       doSomething()
    } else {
       doSomething()
    }
  }
  B -> {
     if (nullableVal != null) {
        doSomething() // test suite only covered nullableVal equal null case, but it is marked as green(covered)
     }
  }
}

But if i add else branch it looks normal

when (someEnum) {
  A -> { ... }
  B -> {
     if (nullableVal != null) {
        doSomething() // Despite being the same test suite, this turns to red(not covered)
     } else {
        doSomething() // and this branch is marked as green(looks normal)
     }
  }
}

Environment

  • Kover Gradle Plugin version: 0.8.2 (but also 0.8.3 is same)
  • Gradle version: 7.6
  • Kotlin project type: Kotlin/JVM
  • Coverage Toolset (if customized in build script): Kover

@shanshin shanshin added S: confirmed Status: bug is reproduced or present Kover Coverage Tool and removed S: untriaged Status: issue reported but unprocessed labels Sep 10, 2024
@shanshin
Copy link
Collaborator

Thanks for the reproducer!

@hqsz
Copy link
Contributor Author

hqsz commented Sep 10, 2024

@shanshin If you need anything, please feel free to tell me 😄

I also have the following questions:

Is it a bug that the null checking inside the if statement branch is marked green even though both the true and false results are not tested? (with upper repository, it is only tested false case) I thought it should be marked in orange (or yellow).

@shanshin
Copy link
Collaborator

Is it a bug that the null checking inside the if statement branch is marked green even though both the true and false results are not tested? (with upper repository, it is only tested false case) I thought it should be marked in orange (or yellow).

Yes, it should be yellow.
However, it seems that when generating a report, when several bytes of instruction code are on the same line, this is not perceived as branching (there may be confusion with Kotlin hided null-check)

@hqsz
Copy link
Contributor Author

hqsz commented Sep 10, 2024

Thanks for answering!

If there is anything I can contribute, I am happy to do so 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Bug issue type Kover Coverage Tool S: confirmed Status: bug is reproduced or present
Projects
None yet
Development

No branches or pull requests

2 participants