Skip to content

build: load Mockito as a startup Java agent for surefire tests - #1483

Merged
copybara-service[bot] merged 1 commit into
mainfrom
test_977387163
Sep 7, 2026
Merged

copybara-service[bot] merged 1 commit into
mainfrom
test_977387163

Conversation

@copybara-service

Copy link
Copy Markdown

build: load Mockito as a startup Java agent for surefire tests

Mockito 5's inline mock maker self-attaches its agent to the running JVM at
runtime, which newer JDKs block, causing mvn test to fail with "Could not
initialize plugin: org.mockito.plugins.MockMaker". Load mockito-core as a
-javaagent (via maven-dependency-plugin resolving its jar path and a per-module
surefire argLine) so the inline mock maker initializes from a startup agent
instead of self-attaching.

Mockito 5's inline mock maker self-attaches its agent to the running JVM at
runtime, which newer JDKs block, causing `mvn test` to fail with "Could not
initialize plugin: org.mockito.plugins.MockMaker". Load mockito-core as a
`-javaagent` (via maven-dependency-plugin resolving its jar path and a per-module
surefire argLine) so the inline mock maker initializes from a startup agent
instead of self-attaching.

PiperOrigin-RevId: 977402752
@copybara-service
copybara-service Bot merged commit 86722a7 into main Sep 7, 2026
7 checks passed
@copybara-service
copybara-service Bot deleted the test_977387163 branch September 7, 2026 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant