You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I run my java spring boot app tests through the UI (the play button), the console shows the warning about java agent being loaded dynamically:
Mockito is currently self-attaching to enable the inline-mock-maker. This will no longer work in future releases of the JDK. Please add Mockito as an agent to your build as described in Mockito's documentation: https://javadoc.io/doc/org.mockito/mockito-core/latest/org.mockito/org/mockito/Mockito.html#0.3
WARNING: A Java agent has been loaded dynamically (/var/home/npessoa/.m2/repository/net/bytebuddy/byte-buddy-agent/1.17.7/byte-buddy-agent-1.17.7.jar)
WARNING: If a serviceability tool is in use, please run with -XX:+EnableDynamicAgentLoading to hide this warning
WARNING: If a serviceability tool is not in use, please run with -Djdk.instrument.traceUsage for more information
WARNING: Dynamic loading of agents will be disallowed by default in a future release
As seen in this stackoverflow post for example, or even in the documentation linked in the warning from the console, this can be resolved by setting up the maven surefire or failsafe plugins with the argLine like this:
That's enough to make the warning go away on my CI/CD pipelines or running the tests through the Intellij IDEA UI. But in the case of vscode, I had to edit my settings.json to include this config, having even to replace the placeholders with static values:
I'm not sure I'm bringing this up in the appropriate place, but I guessed the vscode-java-test plugin could be responsible for this, so I though posting this here.
Hi Noberto Pessoa (@nneto), 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.
You’re hitting a known limitation of the VS Code Java Test Runner: it doesn’t pick up your Maven argLine and even the vmArgs/args in java.test.config aren’t applied today. Workarounds:
• Run tests via Maven so Surefire/Failsafe’s <argLine> is applied:
• Add in your POM’s <build><plugins>: xml <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <argLine>@{argLine} -javaagent:${settings.localRepository}/org/mockito/mockito-core/${mockito.version}/mockito-core-${mockito.version}.jar</argLine> </configuration> </plugin>
• Run mvn test (or use the Maven for Java sidebar) instead of the play button.
• Use a dedicated launch configuration in .vscode/launch.json (the Test Runner will pick this up if you select it):
Then pick JUnit with Mockito Agent from the test-runner dropdown.
Duplicate reports you may want to track:
• #852 – the vmArgs key isn’t aligned to the launch configuration: #852
• #1699 – the args array is ignored entirely: #1699
Other references with low confidence
• None
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!
Activity
github-actions commentedon Nov 7, 2025
Hi Noberto Pessoa (@nneto), 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.
You’re hitting a known limitation of the VS Code Java Test Runner: it doesn’t pick up your Maven
argLineand even thevmArgs/argsinjava.test.configaren’t applied today. Workarounds:• Run tests via Maven so Surefire/Failsafe’s
<argLine>is applied:• Add in your POM’s
<build><plugins>:xml <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <argLine>@{argLine} -javaagent:${settings.localRepository}/org/mockito/mockito-core/${mockito.version}/mockito-core-${mockito.version}.jar</argLine> </configuration> </plugin>• Run
mvn test(or use the Maven for Java sidebar) instead of the play button.• Use a dedicated launch configuration in
.vscode/launch.json(the Test Runner will pick this up if you select it):{ "version": "0.2.0", "configurations": [ { "type": "java", "request": "launch", "name": "JUnit with Mockito Agent", "mainClass": "org.eclipse.jdt.internal.junit.runner.RemoteTestRunner", "projectName": "<your-project>", "vmArgs": [ "-javaagent:${env:HOME}/.m2/repository/org/mockito/mockito-core/5.17.0/mockito-core-5.17.0.jar", "-Xshare:off" ] } ] }Then pick JUnit with Mockito Agent from the test-runner dropdown.
Duplicate reports you may want to track:
• #852 – the
vmArgskey isn’t aligned to the launch configuration: #852• #1699 – the
argsarray is ignored entirely: #1699Other references with low confidence
• None
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!