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

Bug: Coverage not shown for subprojects in Explorer and Testing tab #1676

Closed dishmaker closed 3 months ago

dishmaker commented 3 months ago

Coverage from jacoco for imported source is not being show in UI. Only the project with unit tests is annotated with coverage percentage. Dependency coverage is ignored in the UI.

Environment:

Step to Reproduce: Set up an eclipse .project and .classpath with another project inside.

Inside (tests) project should contain .classpath with classpathentry src=/MainProject.

Run JUnit test coverage in a project MyProject_Tests which imports MainProject with: Ctrl+Shift+P: Test: Run All Tests with Coverage

Expected Behavior: Coverage generated for MyProject_Tests and MainProject too.

Actual Behavior: Only MyProject_Tests coverage is shown in Explorer and Testing tab.

Note: jacoco.exec is generated with subproject class paths. However, VSCode shows coverage only for the _Tests project.

jdneo commented 3 months ago

Seems like this part of the code should be improved:

https://github.com/microsoft/vscode-java-test/blob/57518613e694d72e0d7e4a330307c878acf44907/java-extension/com.microsoft.java.test.plugin/src/main/java/com/microsoft/java/test/plugin/coverage/CoverageHandler.java#L120-L122

For example, expand the classpath when it's a project/container, and persist all output -> source root relationships for those new discovered source kind entry.

jdneo commented 3 months ago

Should be fixed by https://github.com/microsoft/vscode-java-test/pull/1639/commits/99faaae53233a453ecc000cc3946c61f66171f02

I'll schedule a pre-release sooner.

jdneo commented 3 months ago

0.40.2024040105 is released which fixes this issue.

dishmaker commented 3 months ago

Works fine. Thanks!