Skip to content

Commit 2b24c6f

Browse files
brunoborgesCopilot
andcommitted
Update Mockito to 5.23.0 for Java 25 support
Mockito 5.17.0 bundled ByteBuddy 1.15.11 which does not support Java 25 class files, causing SchedulerShutdownRaceTest and ZeroTimeoutContractTest to fail with 'Mockito cannot mock this class'. - Upgrade mockito-core from 5.17.0 to 5.23.0 (includes ByteBuddy 1.17.5+) - Add JDK 21+ profile that passes -XX:+EnableDynamicAgentLoading to Surefire, allowing Mockito/ByteBuddy to attach at runtime (JEP 451) - Use a default-empty surefire.jvm.args property so JDK 17-20 are unaffected by the flag Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent af232de commit 2b24c6f

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

pom.xml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151
<copilot.tests.dir>${copilot.sdk.clone.dir}/test</copilot.tests.dir>
5252
<!-- Set to true (via -Pskip-test-harness) to skip git-clone + npm install of test harness -->
5353
<skip.test.harness>false</skip.test.harness>
54+
<!-- Extra JVM args for Surefire; overridden by the jdk21+ profile -->
55+
<surefire.jvm.args />
5456
</properties>
5557

5658
<dependencies>
@@ -89,7 +91,7 @@
8991
<dependency>
9092
<groupId>org.mockito</groupId>
9193
<artifactId>mockito-core</artifactId>
92-
<version>5.17.0</version>
94+
<version>5.23.0</version>
9395
<scope>test</scope>
9496
</dependency>
9597
</dependencies>
@@ -245,8 +247,8 @@
245247
<artifactId>maven-surefire-plugin</artifactId>
246248
<version>3.5.4</version>
247249
<configuration>
248-
<!-- Inject JaCoCo agent for coverage collection during test runs -->
249-
<argLine>${testExecutionAgentArgs}</argLine>
250+
<!-- Inject JaCoCo agent + any JDK-version-specific flags -->
251+
<argLine>${testExecutionAgentArgs} ${surefire.jvm.args}</argLine>
250252
<systemPropertyVariables>
251253
<copilot.tests.dir>${copilot.tests.dir}</copilot.tests.dir>
252254
<copilot.sdk.dir>${copilot.sdk.clone.dir}</copilot.sdk.dir>
@@ -543,6 +545,18 @@
543545
</reporting>
544546

545547
<profiles>
548+
<!-- Enable dynamic agent loading on JDK 21+ so Mockito/ByteBuddy
549+
can attach at runtime (JEP 451). The flag does not exist on
550+
earlier JDKs, so it must be conditional. -->
551+
<profile>
552+
<id>jdk21+</id>
553+
<activation>
554+
<jdk>[21,)</jdk>
555+
</activation>
556+
<properties>
557+
<surefire.jvm.args>-XX:+EnableDynamicAgentLoading</surefire.jvm.args>
558+
</properties>
559+
</profile>
546560
<!-- Skip git-clone + npm install of the copilot-sdk test harness -->
547561
<profile>
548562
<id>skip-test-harness</id>

0 commit comments

Comments
 (0)