Closed spragunr closed 4 months ago
Would you mind sharing the sample project to us?
@jdneo Here it is:
Thank you! I can reproduce it. Full stacktrace:
java.io.IOException: Error while analyzing C:\Users\....
at org.jacoco.core.analysis.Analyzer.analyzerError(Analyzer.java:163)
at org.jacoco.core.analysis.Analyzer.analyzeClass(Analyzer.java:135)
at org.jacoco.core.analysis.Analyzer.analyzeClass(Analyzer.java:158)
at org.jacoco.core.analysis.Analyzer.analyzeAll(Analyzer.java:195)
at org.jacoco.core.analysis.Analyzer.analyzeZip(Analyzer.java:267)
at org.jacoco.core.analysis.Analyzer.analyzeAll(Analyzer.java:198)
at org.jacoco.core.analysis.Analyzer.analyzeAll(Analyzer.java:228)
at org.jacoco.core.analysis.Analyzer.analyzeAll(Analyzer.java:223)
at org.jacoco.core.analysis.Analyzer.analyzeAll(Analyzer.java:223)
at com.microsoft.java.test.plugin.coverage.CoverageHandler.getCoverageDetail(CoverageHandler.java:91)
at com.microsoft.java.test.plugin.handler.TestDelegateCommandHandler.executeCommand(TestDelegateCommandHandler.java:85)
at org.eclipse.jdt.ls.core.internal.handlers.WorkspaceExecuteCommandHandler$1.run(WorkspaceExecuteCommandHandler.java:230)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
at org.eclipse.jdt.ls.core.internal.handlers.WorkspaceExecuteCommandHandler.executeCommand(WorkspaceExecuteCommandHandler.java:220)
at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$4(JDTLanguageServer.java:604)
at org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:87)
at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(Unknown Source)
at java.base/java.util.concurrent.CompletableFuture$Completion.exec(Unknown Source)
at java.base/java.util.concurrent.ForkJoinTask.doExec(Unknown Source)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source)
at java.base/java.util.concurrent.ForkJoinPool.scan(Unknown Source)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(Unknown Source)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source)
Caused by: java.lang.IllegalStateException: Can't add different class with same name: org/junit/platform/commons/util/ModuleUtils
at org.jacoco.core.analysis.CoverageBuilder.visitCoverage(CoverageBuilder.java:106)
at org.jacoco.core.analysis.Analyzer$1.visitEnd(Analyzer.java:100)
at org.objectweb.asm.ClassVisitor.visitEnd(ClassVisitor.java:395)
at org.jacoco.core.internal.flow.ClassProbesAdapter.visitEnd(ClassProbesAdapter.java:100)
at org.objectweb.asm.ClassReader.accept(ClassReader.java:749)
at org.objectweb.asm.ClassReader.accept(ClassReader.java:425)
at org.jacoco.core.analysis.Analyzer.analyzeClass(Analyzer.java:117)
at org.jacoco.core.analysis.Analyzer.analyzeClass(Analyzer.java:133)
... 21 more
It turns out that for some reason, the junit jar is also included in the bin folder, and be analyzed by jacoco. (Usually, jacoco should only analyze user's source code.)
To avoid this exception, one thing you can do is explicitly declare the source, lib, output location of your project. You can do the following steps to achieve that:
.vscode/settings.json
in your project root.src
and bin
folder in your project root..vscode/settings.json
, add:
"java.test.config": {
"coverage": {
"appendResult": false,
}
},
"java.project.sourcePaths": [
"src"
],
"java.project.referencedLibraries": [
"lib/junit-platform-console-standalone-1.11.0-M2.jar"
],
"java.project.outputPath": "bin"
src
Then everything should be fine.
Coverage testing isn't working for me. When I run with coverage, the progress monitor spins indefinitely and no coverage information is provided. The test results are displayed correctly if I run without coverage.
This is in an unmanaged folder with a single HelloWorld file and a single JUnit5 test file. No workspace settings are provided.
I'm seeing the following error in the extension host logs:
The only extensions I have installed are from the "Extension Pack For Java".
vscode-java-test Extension version: 0.41.1 VS Code Version: Version: 1.91.1 Commit: f1e16e1e6214d7c44d078b1f0607b2388f29d729 Date: 2024-07-09T22:08:12.169Z Electron: 29.4.0 ElectronBuildId: 9728852 Chromium: 122.0.6261.156 Node.js: 20.9.0 V8: 12.2.281.27-electron.0 OS: Linux x64 5.15.0-116-generic