vsCode java.test.config vmArgs not working
Asked Answered
J

1

7

My project requires the following vmArgs to run :

"vmArgs": "-javaagent:lib/aspectjweaver-1.9.5.jar -javaagent:lib/spring-instrument-5.2.3.RELEASE.jar --module-path lib/javafx-sdk-13.0.2/lib --add-modules=javafx.controls"

Putting this in the launch.json configuration object makes the project run perfectly. For unit tests, the same vmArgs should be put into the settings.json's java.test.config object, which I did as you see below :

{
    "java.test.config": 
    [
        {
            "name": "testConfig",
            "workingDirectory": "${workspaceFolder}",
            "vmArgs": "-javaagent:lib/aspectjweaver-1.9.5.jar -javaagent:lib/spring-instrument-5.2.3.RELEASE.jar --module-path lib/javafx-sdk-13.0.2/lib --add-modules=javafx.controls"
        }
    ],
    "java.test.defaultConfig": "testConfig"
}

This part is not working. My JUnit tests are not being instrumented correctly. What am I doing wrong? The vmArgs line is an exact copy of what I have in launch.json.

Jeffry answered 19/2, 2020 at 16:37 Comment(4)
Anyone working on a Java project in vsCode where unit tests require JVM arguments?Jeffry
I haven't used JUnit test case within Visual Studio code. However, while comparing your configuration against an example at code.visualstudio.com/docs/java/java-testing, I noticed differences -- (i) JSON structure (you have used array for java.test.config) and (ii) arguments are proivided in a comma separated list enclosed in a square bracket. Could this be a reason? What is an exact error message you are getting?Grew
No error per se but the tests fail because the JVM is not being properly instrumented before the Spring context starts therefore said context can't even initialize. I saw that page you linked and I think I tried it like that also but I will give it another shot.Jeffry
Sadly this does not work either : "vmArgs": ["-javaagent:lib/aspectjweaver-1.9.5.jar","-javaagent:lib/spring-instrument-5.2.3.RELEASE.jar","--module-path lib/javafx-sdk-13.0.2/lib","--add-modules=javafx.controls"]Jeffry
C
2

I think it might be caused by the capitalization. Previously, it's vmargs not vmArgs. But the extension has changed to support both in this PR: https://github.com/microsoft/vscode-java-test/pull/1080

Do you still have this issue now?

Clearcut answered 26/11, 2020 at 9:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.