Run test with coverage keeps running and never stop
Environment:
- VS Code Version: 1.100.1
- Extension Version: vscode java 1.42.0 + pack 0.29.0
- JDK Type & Version: 17
- OS Type & Version: linux
Step to Reproduce:
- Open project https://github.com/jdneo/invisble-project
- Test Runner explorer > Run test with coverage
Expected Behavior: Testing can be stopped when it's completed
Actual Behavior:
It keeps running and never stop.
Hello! First time contributing so please let me know if any of this is done wrong.
Reproduced on:
- VS Code Version: 1.102.1
- Extension Version: 0.43.1
- JDK Type & Version: Repro on 21 and 24
- OS Type & Version: Win11, Win10
Notes:
I've spent a bit of time digging into this. I'm a rising junior in uni, so thoroughly inexperienced with this level of code, but here's my chain of thought and what I found:
- There appears to be some sort of off-by-one issue going on in counting tests, when clicking run tests or run with coverage, the test counter consistently counts
n+1as the total tests, wherenis the number of tests. For example, in the screenshot below (0/16), there are only 15 tests. "Run Tests" will correct itself, but "Run w/ Coverage" will not. Furthermore, "Run with Coverage" will freeze consistently after passingntests (as you can see in the original ticket's media). Quite frankly, my gut feeling makes me think that all tasks run fine, but it thinks there's still one more to check and gets stuck waiting for that. It will, of course, never come. - I poked around for quite a while, and ended up digging into the jacoco dependency. If you view the "Output" tab, under the task "Language Support for Java" while "Run w/ coverage" is frozen, you will notice an error output (image below). I'm seeing an IOException in Analyzer.java, seemingly related to this function.
At this point, it's pretty over my head, but my suspicion is that there is a "ghost task" (as mentioned in point #1). This gets fed to Jacoco, which crashes. Run with Coverage is left waiting infinitely for a coverage report from Jacoco that will never come.
Again, this is pretty above my level, but I wanted to at least take an honest swing at trying to help out with this. Please let me know if there's other info you would like me to look into.
Hi @yuyully, 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.
The coverage run never terminates because the underlying test session doesn’t exit. Known issues and suggestions:
• Cannot abort a hanging test-session (#101) – After tests finish, the “Running Tests” spinner never stops and the Java process remains alive. – No workaround yet; you can track progress or vote on https://github.com/microsoft/vscode-java-test/issues/101
• A test session is currently running… (#857) – The client reports a session in flight even after tests complete. Closing and rerunning doesn’t clear it. – See https://github.com/microsoft/vscode-java-test/issues/857
• Running a test constantly churns and never starts (#1038) – Related hanging behavior when running or debugging tests. – Some users report success after cleaning workspace, updating extensions, and restarting VS Code: https://github.com/microsoft/vscode-java-debug/issues/1038
Suggestions:
• Update to the latest Java Test Runner and Java Debug extensions (>= 0.33.x) and VS Code Java pack (>= 0.30.x). • Reload the window or restart VS Code after extension updates. • Clean all workspace caches: close VS Code, delete the “.java” and “.testresults” folders, then reopen. • As a temporary workaround, run coverage via Maven/Gradle in a terminal to ensure proper process termination.
labels:
- bug
- junit
- test-execution
- investigating
duplicateUrls: []
Other references with low confidence
• Java projects suddenly stopped loading (#1049) – Project import stall unrelated to test hang. https://github.com/microsoft/vscode-java-pack/issues/1049
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!