Skip to content

Commit bfde394

Browse files
committed
Add mockito-core javaagent for future Java compatibility
https://javadoc.io/doc/org.mockito/mockito-core/latest/org/mockito/Mockito.html#0.3 warns that Java version 21 and later report a warning when trying to use Mockito without the javaagent. Followed the instructions in their documentation to add mockito javaagent.
1 parent 2ac8d07 commit bfde394

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

pom.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,13 +291,28 @@
291291

292292
<build>
293293
<plugins>
294+
<plugin>
295+
<!-- Needed by the mockito-core properties reference in surefire -->
296+
<groupId>org.apache.maven.plugins</groupId>
297+
<artifactId>maven-dependency-plugin</artifactId>
298+
<executions>
299+
<execution>
300+
<goals>
301+
<goal>properties</goal>
302+
</goals>
303+
</execution>
304+
</executions>
305+
</plugin>
294306
<plugin>
295307
<groupId>org.apache.maven.plugins</groupId>
296308
<artifactId>maven-surefire-plugin</artifactId>
297309
<configuration>
298310
<systemPropertyVariables>
299311
<org.jenkinsci.plugins.gitclient.verifier.SshHostKeyVerificationStrategy.jgit_known_hosts_file>${project.build.directory}/ssh/know_hosts</org.jenkinsci.plugins.gitclient.verifier.SshHostKeyVerificationStrategy.jgit_known_hosts_file>
300312
</systemPropertyVariables>
313+
<!-- Add mockito javaagent for the MockitoJUnitRunner in Java 21 and beyond -->
314+
<!-- https://javadoc.io/doc/org.mockito/mockito-core/latest/org/mockito/Mockito.html#0.3 -->
315+
<argLine>@{argLine} -javaagent:${org.mockito:mockito-core:jar}</argLine>
301316
</configuration>
302317
</plugin>
303318
<plugin>

0 commit comments

Comments
 (0)