Skip to content

Replace mockito-android mock maker implementation with dexmaker-mockito-inline#3792

Merged
raphw merged 1 commit intomockito:mainfrom
jselbo:android-v3
Mar 4, 2026
Merged

Replace mockito-android mock maker implementation with dexmaker-mockito-inline#3792
raphw merged 1 commit intomockito:mainfrom
jselbo:android-v3

Conversation

@jselbo
Copy link
Copy Markdown
Collaborator

@jselbo jselbo commented Mar 4, 2026

See #3789 for a previous discussion on this

For now it is probably better to just depend on dexmaker-mockito-inline . If we need more flexibility or the dexmaker project is not responsive, we can fork it in the future.

Note this means mockito-android is now published as an Android library (.aar instead of .jar). This also removes the graceful fallback behavior if this mock maker was included on a non-Android JVM - now invoking a Mockito API will fail with a runtime exception instead of falling back to the subclass mockmaker.

I also updated the Android sections in the Javadoc appropriately

Checklist

  • Avoid other runtime dependencies

This adds a new compile dependency for mockito-android on com.linkedin.dexmaker:dexmaker-mockito-inline which allows runtime generation of Android dex byte code, similar to Byte-Buddy on the JVM.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.91%. Comparing base (25f1395) to head (455a1c0).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #3792      +/-   ##
============================================
+ Coverage     86.50%   86.91%   +0.41%     
+ Complexity     3004     2997       -7     
============================================
  Files           343      340       -3     
  Lines          9099     9020      -79     
  Branches       1121     1105      -16     
============================================
- Hits           7871     7840      -31     
+ Misses          945      904      -41     
+ Partials        283      276       -7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@raphw
Copy link
Copy Markdown
Member

raphw commented Mar 4, 2026

This looks good to me! I think a best start and we can always move to a fork if there is a need that justifies this step. Also easier to maintain and upgrade for a non-expert!

@raphw raphw merged commit f6a91a6 into mockito:main Mar 4, 2026
19 checks passed
@jselbo jselbo deleted the android-v3 branch March 4, 2026 20:21
@davwheat
Copy link
Copy Markdown

Would you be able to highlight the breaking change this results in more clearly within the changelog?

We still support SDK26 in our app, so run tests on that version, and I've just spent the last 6 hours banging my head against the wall trying to work out how I have broken all my instrumented tests :p

@jselbo
Copy link
Copy Markdown
Collaborator Author

jselbo commented Mar 13, 2026

@davwheat Sorry about the bad experience. Good call - I will update the release notes to more clearly state this breaking change!

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.

4 participants