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

Jacoco coverage report won't reflect latest change #489

Closed
jason1peng opened this issue Oct 13, 2023 · 3 comments · Fixed by #490
Closed

Jacoco coverage report won't reflect latest change #489

jason1peng opened this issue Oct 13, 2023 · 3 comments · Fixed by #490
Assignees
Labels
Bug Bug issue type Kover Gradle Plugin S: ready for release Status: merged in the main branch

Comments

@jason1peng
Copy link

Describe the bug
Jacoco report was not update correctly after delete one of the tests.
Coverage report still showing object is covered.

Errors

Expected behavior
Coverage report should show object is not covered.

Reproducer
Basic project with two test file.

build.gradle.kts

plugin {
  id("org.jetbrains.kotlinx.kover") version "0.7.4"
}
...
kover {
    useJacoco("0.8.10")
}

Target class

object HelloWorld {
    fun hello() = "Hello"
    fun world() = "${hello()} World"
}

Test file 1

class HelloTest : DescribeSpec({
    describe("hello") {
        context("hello") {
            it("should return hello") {
                HelloWorld.hello() shouldBe "Hello"
            }
        }
    }
})

Test file 2

import io.kotest.core.spec.style.DescribeSpec
import io.kotest.matchers.shouldBe

class WorldTest : DescribeSpec({

    describe("world") {
        context("world") {
            it("should return hello world") {
                HelloWorld.world() shouldBe "Hello World"
            }
        }
    }

})
  • trigger koverHtmlReport task, I could see HelloWorld class is covered 100%.
  • delete test file 2, trigger koverHtmlReport task, HelloWorld class still covered 100%.

Reports

Environment

  • Kover Gradle Plugin version: 0.7.4
  • Gradle version: 7.6.1
  • Kotlin project type: Kotlin
  • Coverage Toolset (if customized in build script): JaCoCo("0.8.10")
  • Other context important for this bug: mac
@jason1peng jason1peng added Bug Bug issue type S: untriaged Status: issue reported but unprocessed labels Oct 13, 2023
@shanshin shanshin added S: confirmed Status: bug is reproduced or present and removed S: untriaged Status: issue reported but unprocessed labels Oct 13, 2023
@shanshin
Copy link
Collaborator

shanshin commented Oct 13, 2023

Thanks for the report!
The problem is not related to JaCoCo.
As workaround, you may run clean before generating the report, or use the Gradle build cache.

shanshin added a commit that referenced this issue Oct 13, 2023
If the build cache is not used and the build directory is not cleared before the test run, then the coverage data from previous test runs are merged with the data from the recent run.
In this case, the report may include coverage from those tests that were removed in the latest version of the code.

To solve this, it is necessary to delete the binary report file before each run of the test task.

Fixes #489
shanshin added a commit that referenced this issue Oct 13, 2023
If the build cache is not used and the build directory is not cleared before the test run, then the coverage data from previous test runs are merged with the data from the recent run.
In this case, the report may include coverage from those tests that were removed in the latest version of the code.

To solve this, it is necessary to delete the binary report file before each run of the test task.

Fixes #489
@jason1peng
Copy link
Author

jason1peng commented Oct 13, 2023

Thanks for the quick update. I tried these two approaches and both won't work.

  1. run gradle clean before generating report.
  2. use --no-build-cach

shanshin added a commit that referenced this issue Oct 13, 2023
If the build cache is not used and the build directory is not cleared before the test run, then the coverage data from previous test runs are merged with the data from the recent run.
In this case, the report may include coverage from those tests that were removed in the latest version of the code.

To solve this, it is necessary to delete the binary report file before each run of the test task.

Fixes #489
PR #490
@shanshin shanshin reopened this Oct 13, 2023
@shanshin shanshin added S: ready for release Status: merged in the main branch and removed S: confirmed Status: bug is reproduced or present labels Oct 13, 2023
@shanshin
Copy link
Collaborator

Fixed in 0.7.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Bug issue type Kover Gradle Plugin S: ready for release Status: merged in the main branch
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants