Skip to content

[BUG] The extension uses raw data. #1880

Open

Description

@ToshiNamura

The extension uses raw data from "src/main/resources" instead of "build/resources/main". Because of this, raw resource data is used during testing.

Configuring the extension solves the problem:

"java.test.config": {
        "workingDirectory": "${workspaceFolder}",
        "classpath": "${workspaceFolder}/build/classes/java/test:${workspaceFolder}/build/resources/main:${workspaceFolder}/build/resources/test"
    }

I think this is a bug, as using raw data from resources leads to incorrect test results.

Activity

  1. github-actions commented on Jul 5, 2026

    @github-actions

    Hi ToshiNamura, 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.

    Solution

    • Override the test runner’s working directory and classpath so it picks up compiled resources instead of raw src/main/resources. For example, add the following to your VS Code settings:

    "java.test.config": {
      "workingDirectory": "${workspaceFolder}",
      "classpath": [
        "${workspaceFolder}/build/classes/java/test",
        "${workspaceFolder}/build/resources/test",
        "${workspaceFolder}/build/resources/main"
      ]
    }

    This forces the Java Test Runner to use the outputs under build/ for both classes and resources during test execution.

    Duplicate issues

    No matching issues found among the provided references.

    Other references with low confidence

    Extension issue #2428

    • Generic bug report about extension logging data to clipboard; unrelated to resource paths
    URL: redhat-developer/vscode-java#2428

    • Similar placeholders-only reports (#1787, #2583, #2641, #2792) all describe generic extension bugs without details on resource resolution.

    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!

  2. wenytang-ms commented on Jul 7, 2026

    @wenytang-ms
    Contributor

    From the Gradle side — same underlying cause as #1878. The default Run Tests profile launches JUnit in a standalone JDT-forked JVM, so Gradle's processResources task never runs and the test reads the raw src/main/resources instead of the processed build/resources/main.

    How to fix it: in the Testing view, click the ⌄ dropdown next to the run button and pick "Delegate Test to Gradle". That runs your tests through Gradle's real test task (which depends on processResources), so the processed resources land on the classpath just like ./gradlew test — no manual classpath override needed. The classpath workaround works but is stale-prone (nothing re-runs processResources) and breaks when the source-set / build layout changes.

    On the Gradle side we're looking at making this delegate path easier to discover; you can follow along at microsoft/vscode-gradle#1890.

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

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions