Cannot Retrieve Coverage Report File Generically in "Test Runner for Java" Extension
When running "Run Test with Coverage" from the VS Code Test Explorer using the "Test Runner for Java" extension, I am unable to find a generic way to locate the coverage report file for each test run.
I am looking for a solution to programmatically retrieve the coverage report file using TypeScript. Any guidance on how to achieve this would be appreciated.
Hi @josesf3937, 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.
Below are some suggestions and references to help you retrieve the coverage report file path:\n\n• Hard-code or infer the report location from your build tool’s standard output paths:\n – Maven: target/jacoco.exec or configured <destFile> in the JaCoCo plugin.\n – Gradle: build/jacoco/test.exec or whichever destinationFile you set.\n In your extension’s TypeScript, you can compute it via:\n ts\n const ws = vscode.workspace.workspaceFolders![0].uri.fsPath;\n const reportPath = path.join(ws, 'target', 'jacoco.exec'); // or 'build/jacoco/test.exec'\n \n\n• Configure a consistent output dir in your POM or build.gradle so you can always derive the path at runtime.\n\n• There’s no built-in VS Code Java-Test API to return the coverage file. You may open a feature request or track the following issue for future support:\n – Bug: Coverage not shown for subprojects (includes CoverageHandler improvements)\n • https://github.com/microsoft/vscode-java-test/issues/1676#issuecomment-2022207631\n\nOther references with low confidence
\n\n• How to set the test folder? Custom test source path FAQ (not about coverage file)\n – https://github.com/microsoft/vscode-java-test/issues/1568#issuecomment-1536967320\n\n
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!