Skip to content

[Engine][Android] Fix Mockito dynamic agent loading warnings in Robolectric tests for JDK compatibility #189148

Description

@gmackall

When running Android engine Robolectric tests (e.g., ./flutter/testing/run_tests.py --type java), Mockito emits deprecation warnings when self-attaching the inline-mock-maker agent on newer JDK releases (JDK 21+):

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/folders/4p/.../byteBuddyAgent...jar)
WARNING: Dynamic loading of agents will be disallowed by default in a future release

To ensure tests do not break when upgrading to future JDK releases where dynamic agent loading is disallowed by default, Mockito should be explicitly configured as a -javaagent in the test JVM arguments, or dynamic agent loading should be explicitly enabled.

Code Links:

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listengineflutter/engine related. See also e: labels.team-androidOwned by Android platform teamtriaged-androidTriaged by Android platform team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions