microsoft / vscode-java-test

Run and debug Java test cases in Visual Studio Code.
https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-test
Other
290 stars 124 forks source link

Code coverage does not clear for a single test run result #1680

Closed gabrieltosetti closed 2 months ago

gabrieltosetti commented 3 months ago

I can run the test coverage for all tests and it shows the percentage just fine but after that if I run a single test with code coverage the result seems to be appended with the last report.

I tried with no success:

I also tried this setting:

{
    "java.test.config": [
        {
            "name": "jacoco",
            "vmargs": ["-Djacoco.append=false"]
        }
    ],
    "java.test.defaultConfig": "jacoco",
}

The only thing that works is deleting all folders from ~/Library/Application Support/Code/User/workspaceStorage/<random hash>/vscjava.vscode-java-test/, running the single test and then I see the coverage only for that execution.

As a side note, my project has submodules

  |- pom.xml
  |- domainModule
  |     |- pom.xml
  |- infrastructureModule
  |     |- pom.xml

VSCode version

Version: 1.88.1
Commit: e170252f762678dec6ca2cc69aba1570769a5d39
Date: 2024-04-10T17:43:08.196Z
Browser: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Code/1.88.1 Chrome/120.0.6099.291 Electron/28.2.8 Safari/537.36

Extension version

0.41.0

OS version

MacOS Sonoma 14.4.1

jdneo commented 2 months ago

Have you tried:

"java.test.config": {
        "coverage": {
            "appendResult": false
        }
    }
gabrieltosetti commented 2 months ago

OMG I search so much for this...it just works!! Thank you so much 😄

Could you update the Wiki to include this new option? https://github.com/microsoft/vscode-java-test/wiki/Run-with-Configuration#property-details

jdneo commented 2 months ago

Good to know it works!

I've added to the wiki so I'm going to close this issue. Let me know if you have more questions, thank you!