microsoft / microsoft/vscode-java-test

Ignoring arg from maven plugin

Offen
#1,810 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

ai-triaged bug junit needs-reproduction test-execution
Vorherrschende Sprache
TypeScript
Sterne
340
Forks
173
Ø Merge
1 T. 19 Std.
Gemergte PRs (30 T.)
18

Beschreibung

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:

<argLine>@{argLine} -javaagent:${settings.localRepository}/org/mockito/mockito-core/${mockito.version}/mockito-core-${mockito.version}.jar</argLine>

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:

"java.test.config": {
  "vmArgs": [
    "-javaagent:/var/home/npessoa/.m2/repository/org/mockito/mockito-core/5.17.0/mockito-core-5.17.0.jar",
    "-Xshare:off"
  ]
}

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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit dem Java-Teststartpfad, der von der UI-Wiedergabeschaltfläche verwendet wird, und untersuche, wie java.test.config vmArgs zusammen mit Maven surefire oder failsafe argLine verarbeitet wird. Vergleiche den generierten Testbefehl mit der dokumentierten Mockito-javaagent-Konfiguration. Als erledigt gilt die Aufgabe, wenn das konfigurierte Agent-Argument beim Starten von Tests über VS Code berücksichtigt wird und die Warnung zum dynamischen Laden nicht mehr ausgegeben wird.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
java, vscode
Bereich
testing, tooling
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.