microsoft / microsoft/vscode-java-test

Cannot add command line arguments via java.test.config

Open
#1,297 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

ai-triaged enhancement test-configuration test-execution testng
Dominant language
TypeScript
Stars
340
Forks
173
Avg merge
1d 19h
Merged PRs (30d)
18

Description

I'm trying to add listeners when running testNG tests using the Java Test runner.

In my settings.xml I've added:

"java.test.config": {
"name": "RunWithContinue",
"workingDirectory": "${workspaceFolder}",
"args": [
"-listener", "org.test.TestFilter"
]
},

But when I run:

[ERROR] {"name":"error","attributes":{"message":"Failed to run TestNG tests","trace":"java.lang.ClassNotFoundException: -listener
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:398)
at com.microsoft.java.test.runner.testng.TestNGLauncher.getClassName(TestNGLauncher.java:53)
at com.microsoft.java.test.runner.testng.TestNGLauncher.parse(TestNGLauncher.java:46)
at com.microsoft.java.test.runner.testng.TestNGLauncher.execute(TestNGLauncher.java:32)
at com.microsoft.java.test.runner.Launcher.main(Launcher.java:57)
"}}

It seems all args are expected to be a Class/Method name, even though it seems to be the only place to pass TestNG command line arguments:

image

Is there a workaround?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the failing stack trace in TestNGLauncher.java, especially parse and getClassName, then inspect how Launcher.java receives settings from java.test.config. Reproduce the case with the shown TestNG listener arguments. Done means the configured arguments are handled as intended by the test runner and the listener configuration no longer produces a ClassNotFoundException.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.