Skip to content

Fix Mockito dynamic agent loading warnings in Robolectric tests#189804

Merged
auto-submit[bot] merged 2 commits into
flutter:masterfrom
mboetger:triage-issue-189148
Jul 22, 2026
Merged

Fix Mockito dynamic agent loading warnings in Robolectric tests#189804
auto-submit[bot] merged 2 commits into
flutter:masterfrom
mboetger:triage-issue-189148

Conversation

@mboetger

@mboetger mboetger commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

This change configures Mockito-core as a -javaagent in the Gradle build file for unit tests using CommandLineArgumentProvider. This prevents dynamic agent loading warnings during Robolectric tests when running on newer JDKs.

Fixes: #189148

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

…ectric tests

This change configures Mockito-core as a -javaagent in the Gradle build file for unit tests using CommandLineArgumentProvider. This prevents dynamic agent loading warnings during Robolectric tests when running on newer JDKs.
@mboetger
mboetger requested a review from a team as a code owner July 21, 2026 21:11
@mboetger
mboetger requested review from gmackall and removed request for a team July 21, 2026 21:11
@mboetger mboetger added the l:backlog LLM created PR addressing a backlog issue. label Jul 21, 2026
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Jul 21, 2026
@flutter-dashboard

Copy link
Copy Markdown

It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request configures a mockitoAgent in the Android test runner's Gradle build to run Mockito as a Java agent during unit tests. The review feedback suggests declaring the agent files as task inputs using @InputFiles and @classpath to ensure correct Gradle build caching, and extracting the duplicated Mockito version string into a local variable to align with the repository's style guide.

Comment thread engine/src/flutter/shell/platform/android/test_runner/build.gradle
Comment thread engine/src/flutter/shell/platform/android/test_runner/build.gradle Outdated
@github-actions github-actions Bot added platform-android Android applications specifically engine flutter/engine related. See also e: labels. team-android Owned by Android platform team labels Jul 21, 2026

@gmackall gmackall left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm if

  1. tests still pass
  2. you validated the warning is gone

gmackall
gmackall previously approved these changes Jul 21, 2026

@gmackall gmackall left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoops meant to approve

@gmackall gmackall left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re-conditional-lgtm

@mboetger

Copy link
Copy Markdown
Contributor Author

Verified warning does not show:

Before After
Mockito Before.webm Mockito After.webm

@mboetger mboetger added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 22, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Jul 22, 2026
Merged via the queue into flutter:master with commit 543e016 Jul 22, 2026
20 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jul 22, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Jul 22, 2026
flutter/flutter@1ac2e82...2a2a79d

2026-07-22 [email protected] Clear cached directional focus history on a non-directional focus request  (flutter/flutter#187957)
2026-07-22 [email protected] ci: Include root pubspec.yaml in pub cache key (flutter/flutter#189826)
2026-07-22 [email protected] Remove codecov badge from README (flutter/flutter#189728)
2026-07-22 [email protected] Clean android engine/embedding tests (flutter/flutter#189276)
2026-07-22 [email protected] Add barrierBuilder support to showDialog and showGeneralDialog (flutter/flutter#187992)
2026-07-22 [email protected] Fix Mockito dynamic agent loading warnings in Robolectric tests (flutter/flutter#189804)
2026-07-22 [email protected] [iOS] Remove dead RasterThreadMerger plumbing from platform views (flutter/flutter#189753)
2026-07-22 [email protected] Add OverlayPortal.overlayChildLayoutBuilder sample (flutter/flutter#188930)
2026-07-22 [email protected] Automate recurring tasks via workflows - localizations (flutter/flutter#189750)
2026-07-21 [email protected] [iOS] Remove dead parameters and no-op overrides (flutter/flutter#189754)
2026-07-21 [email protected] [iOS] Inject DisplayLinkManager into FlutterViewController (flutter/flutter#189764)
2026-07-21 [email protected] Support custom BoxBorder animation in BoxDecoration (flutter/flutter#186348)
2026-07-21 [email protected] Rename CpuArch.x86_64 to CpuArch.x64 (flutter/flutter#189478)
2026-07-21 [email protected] Roll Skia from 569534e9fa59 to 5e183e5aeac5 (3 revisions) (flutter/flutter#189795)
2026-07-21 [email protected] Roll Dart SDK from 3b2f5ad7718d to 1e65011ee004 (4 revisions) (flutter/flutter#189791)
2026-07-21 [email protected] Run delete-bot-branches.yaml on `pull_request_target` instead of `pull_request` so that we can access secrets. (flutter/flutter#189793)
2026-07-21 [email protected] Batch release directory correction (flutter/flutter#189738)
2026-07-21 [email protected] [flutter_test][Test cross imports] Move TestWidgetsApp to flutter_test (flutter/flutter#189435)
2026-07-21 [email protected] Fix null-deref/double-dispose in StretchingOverscrollIndicator (#189589) (flutter/flutter#189667)
2026-07-21 [email protected] Roll Packages from 611899b to 8260a1e (10 revisions) (flutter/flutter#189782)
2026-07-21 [email protected] [iOS] Inject DisplayLinkManager into FlutterMetalLayer (flutter/flutter#189752)
2026-07-21 [email protected] Derive the SkImage size used by ImageEncodingImpeller::ConvertDlImageToSkImage from the size of the underlying texture, not the size of the DlImage (flutter/flutter#189739)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD engine flutter/engine related. See also e: labels. l:backlog LLM created PR addressing a backlog issue. platform-android Android applications specifically team-android Owned by Android platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants