GH-1033 - Prevent dynamic agent attachment warnings caused by Mockito.

Prior to this commit, running our tests caused the following warning because Mockito was dynamically self-attaching to the running JVM:

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 what is described in Mockito's documentation: https://javadoc.io/doc/org.mockito/mockito-core/latest/org/mockito/Mockito.html#0.3

We now follow the advice in the provided link and set up our build accordingly.
This commit is contained in:
Oliver Drotbohm
2025-01-23 16:53:00 +01:00
parent dcde35385c
commit f6dd7836c2
3 changed files with 39 additions and 0 deletions

14
pom.xml
View File

@@ -562,6 +562,18 @@ limitations under the License.
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>properties</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
@@ -569,6 +581,8 @@ limitations under the License.
<excludes>
<exclude />
</excludes>
<!-- To avoid warnings of Mockito dynamically attaching an agent -->
<argLine>-javaagent:${org.mockito:mockito-core:jar}</argLine>
</configuration>
</plugin>

View File

@@ -63,6 +63,12 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>

View File

@@ -93,6 +93,25 @@
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>properties</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!-- To avoid warnings of Mockito dynamically attaching an agent -->
<argLine>-javaagent:${org.mockito:mockito-core:jar}</argLine>
</configuration>
</plugin>
</plugins>
</build>