vscode-java-debug icon indicating copy to clipboard operation
vscode-java-debug copied to clipboard

Wrong/strange classpath in test runner

Open dsyer opened this issue 2 years ago • 3 comments

[provide a description of the issue]

Environment
  • Operating System: Linux
  • JDK version: 11
  • Visual Studio Code version: 1.63.2
  • Java extension version: v0.21.0
  • Java Debugger extension version: v0.38.0
Steps To Reproduce
  1. Try to run a test that reads a properties file from classpath
  2. Fail
Additional Informations

A break point in the test reveals that the classpath starts with bin/main and does not contain the Gradle build dirs. I see the compiled classes at bin/main but no resources like properties files etc from src/main/resources. What is this bin/main? Gradle puts classes in build/classes/main and resources in build/resources/main, so where did the bin directory come from? If I delete it, it is re-created, so I suspect the VSCode Java extensions are doing that.

Related underlying issue: https://github.com/redhat-developer/vscode-java/issues/634

dsyer avatar Mar 04 '22 09:03 dsyer

@dsyer thanks for reaching out.

yes, it's an issue with vscode-java extension, the debugger is reusing the same build output from vscode-java extension. Looks like it doesn't copy the resources to the output directory. https://github.com/redhat-developer/vscode-java/issues/634 is a little old, we need to create a new issue on redhat-developer/vscode-java for that. It would be nice to have a minimum sample project.

testforstephen avatar Mar 07 '22 01:03 testforstephen

In addition to above problem about the classpath, the order of classpath is also very strange. why bin/test is behind of bin/main? we should put bin/test int the front for correctly loading test config files, especially for the case there are different config files for running and testing env. and I wan't know whether there have a way to change the order of classpath.

lingjiameng avatar Mar 07 '22 08:03 lingjiameng

@lingjiameng There are some issues for Gradle classpath resolving. But the problem should be fixed if we support delegate testing to gradle directly. Please vote for https://github.com/microsoft/vscode-java-test/issues/1045 if you would like to have it.

jdneo avatar Nov 16 '22 00:11 jdneo