Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong/strange classpath in test runner #1127

Closed
dsyer opened this issue Mar 4, 2022 · 4 comments
Closed

Wrong/strange classpath in test runner #1127

dsyer opened this issue Mar 4, 2022 · 4 comments

Comments

@dsyer
Copy link

dsyer commented Mar 4, 2022

[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: redhat-developer/vscode-java#634

@testforstephen
Copy link
Contributor

@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. redhat-developer/vscode-java#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.

@lingjiameng
Copy link

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.

@jdneo
Copy link
Member

jdneo commented Nov 16, 2022

@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 microsoft/vscode-java-test#1045 if you would like to have it.

@jdneo
Copy link
Member

jdneo commented Aug 5, 2024

The Gradle Test Delegation (both run and debug) has supported now.

To use this feature, you need to install the latest Test Runner for Java and Gradle for Java extension.

To delegate the tests to Gradle, you can set the default testing profile in Testing explorer:
image
image

If you do not want to change the default testing profile, you can trigger an one-time execution via:
image
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants