Code coverage: execution count not correct
Version: 1.90.0 (Universal) Commit: 89de5a8d4d6205e5b11647eb6a74844ca23d2573 Date: 2024-06-04T19:34:44.157Z Electron: 29.4.0 ElectronBuildId: 9593362 Chromium: 122.0.6261.156 Node.js: 20.9.0 V8: 12.2.281.27-electron.0 OS: Darwin x64 23.5.0 Test Runner for Java v0.41.1
Steps to reproduce:
- Run code coverage tool on Java project.
- Show inline coverage in editor window.
- The execution count shown alongside each statement is not correct.
Example: hovering over the "6x" decoration on line 41, the pop-up indicates the statement was executed 6 times:
I believe it is displaying the instruction count for line 41 found in the Jacoco report:
In any case, it would be great to have the option to turn off these decorations.
In any case, it would be great to have the option to turn off these decorations.
Are you using insider vscode or stable?
Yes, it's displaying the ci as the count. Is that wrong in this case?
I am using the stable release.
If the intention is to display the ci, the tooltip needs to be updated to reflect this. On line 41 in the example above, the tooltip text is "y = y + DY; was executed 6 times" but it should say something like "Instruction count: 6". I believe the ci is a count of the number of Java byte code instructions that were executed on the corresponding line, not a count of the number of times the Java statement was executed by the tests. (https://www.jacoco.org/jacoco/trunk/doc/counters.html)
In stable, you can hover on the colored line number, wait for 1 second, you will see the toggle action to close the inline decoration.
If the intention is to display the ci, the tooltip needs to be updated to reflect this.
Yes, looks there is some gap here. The API from VS Code only have line/statement coverage, which is not fully equal to the ci.
Hi @pcarterubc, I'm an AI Support assistant here to help with your issue. While the team reviews your request, I wanted to provide some possible tips and documentation that might help you in the meantime.
It turns out what you’re seeing (“6x” on line 41) is the ci (covered‐instructions) count reported by JaCoCo rather than the number of times that line actually executed. At present there isn’t a way to switch the decorator off or show true per-line execution counts. Your options today are:
• Disable the inline coverage decorator globally (no explicit setting exists yet):
- Open Command Palette (⇧⌘P / Ctrl+Shift+P)
- Run “Disable Inline Coverage Decorator” (or search for “coverage” to see any new commands added by the Java Test extension)
• Limit JaCoCo output to line-level coverage only by configuring your build (e.g. in Maven’s pom.xml):
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<configuration>
<output>file</output>
<excludes>
<exclude>**/your/unwanted/**</exclude>
</excludes>
</configuration>
</plugin>
(JaCoCo still reports instruction counts internally, but you can tune which packages/classes it instruments.)
• If you’d like an explicit setting to hide these counts (or to show true execution counts), please file a feature request: https://github.com/microsoft/vscode-java-test/issues/new?template=feature_request.md
No existing issues cover this exact need; I recommend opening a dedicated feature request so that the team can track adding a configuration knob.
labels:
- bug
- ui
- test-reporting
- needs-reproduction
duplicateUrls: []
The team will respond to your issue shortly. I hope these suggestions are helpful in the meantime. If this comment helped you, please give it a 👍. If the suggestion was not helpful or incorrect, please give it a 👎. Your feedback helps us improve!