Skip to content

args being ignored #1699

Open
Open

Description

@dbmckie

I have set the following configuration in settings.json:

"java.test.config": {
    "coverage": {
        "appendResult": false
    },
    "testKind": "junit",
    "args": ["--exclude-package=test.package.to.ignore"]
}

But it does not appear that the args array is being passed to the test runner. From the logs:

INFO: Trying to launch Java Program with options:
main-class: org.eclipse.jdt.internal.junit.runner.RemoteTestRunner
args: -version 3 -port 64185 -testLoaderClass org.eclipse.jdt.internal.junit5.runner.JUnit5TestLoader -loaderpluginname org.eclipse.jdt.junit5.runtime -testNameFile C:\Users\user\AppData\Local\Temp\testNames3476799342913323661.txt
module-path:
class-path:
vmArgs: -ea -Dfile.encoding=UTF-8 -cp "C:\Users\user\AppData\Local\Temp\cp_a9xn9vku4dypkzk1huwivwhyw.jar"

Activity

  1. dbmckie commented on Jun 13, 2024

    @dbmckie
    Author

    Tested with

    "args": [
        "--exclude-tag=test_tag",
        "--exclude-tag", "test_tag"
    ]
    

    Output:
    args: -version 3 -port 64962 -testLoaderClass org.eclipse.jdt.internal.junit5.runner.JUnit5TestLoader -loaderpluginname org.eclipse.jdt.junit5.runtime -testNameFile C:\Users\user\AppData\Local\Temp\testNames12627821658992615585.txt

    to compare with

    "filters": {
        "tags": ["!test_tag"]
    }
    

    Output:
    args: -version 3 -port 64633 -testLoaderClass org.eclipse.jdt.internal.junit5.runner.JUnit5TestLoader -loaderpluginname org.eclipse.jdt.junit5.runtime -testNameFile C:\Users\user\AppData\Local\Temp\testNames590903279624443577.txt --exclude-tag test_tag

  2. github-actions commented on Nov 12, 2025

    @github-actions

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

    It looks like the built-in JDT test runner (RemoteTestRunner) does not pick up the args array unless you explicitly map it to a named test profile that you then select. Here are a couple of approaches to try:

    • Align your config name with the launch config (issue #852):

    // settings.json
    "java.test.config": [
      {
        // must match the name VS Code shows when launching tests
        "name": "Launch Java Tests",
        "testKind": "junit",
        "args": ["--exclude-package=test.package.to.ignore"]
      }
    ]

    Then pick that profile via the Test Explorer’s “Execute Using Profile…” menu.

    • If you need full ConsoleLauncher support (so that --exclude-package is honored), create a custom launch.json entry instead of using the JDT runner:

    // .vscode/launch.json
    {
      "configurations": [
        {
          "name": "ConsoleLauncher Tests",
          "type": "java",
          "request": "launch",
          "mainClass": "org.junit.platform.console.ConsoleLauncher",
          "args": [
            "--exclude-package=test.package.to.ignore",
            // add other ConsoleLauncher options here
          ],
          "classpath": [
            "${workspaceFolder}/target/test-classes",
            "${workspaceFolder}/target/classes"
          ]
        }
      ]
    }

    References:

    Other references with low confidence

    • Issue #1508/#1427 – about Gradle test delegation; unlikely to affect JDT arg passing. #1508 (comment)

    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!

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions