Skip to content

Wrong/strange classpath in test runner #1127

Closed

Description

@dsyer

[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

Activity

  1. testforstephen commented on Mar 7, 2022

    @testforstephen
    Contributor

    Dave Syer (@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.

  2. lingjiameng commented on Mar 7, 2022

    @lingjiameng

    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.

  3. jdneo commented on Nov 16, 2022

    @jdneo
    Member

    岂曰无衣 (@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.

  4. jdneo commented on Aug 5, 2024

    @jdneo
    Member

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions