New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Regression starting in mockito-inline 4.7.0? #2860
Comments
I am not sure what is going on here, but looking at the test I feel like you want to use |
Thanks, @TimvdLippe! I've tried the changes you suggested and opened a PR. It definitely works with the current version of mockito and we'll see how my team feels about it. One hiccup with the change--I couldn't come up with a correct way to instantiate an |
Hm. I would have assumed that you can create the captor just like the others, with the Given that the fix works, I am inclined to close this issue as WAI. |
@TimvdLippe, the @captor worked--I had tried it but got hung up on the parameter matching. Fixed now, thanks! Re: WAI, I couldn't find any indication of intentionally deprecating the old behavior, even if preferred options were available. Breaking behavior accidentally is generally considered a regression, but your team will ultimately make that call. Thanks again for your help on this! |
We didn't intentionally break it, but I think this is a case of https://www.hyrumslaw.com/ Luckily we have alternatives in our public API that should suit your use case. Thanks for raising the issue! |
#### Details Due to mockito/mockito#2860, Dependbot has been unable to update to any version of `mockito-inline` since version 4.6.1. The failed attempts are as follows: Version | Failed PR --- | --- 4.7.0 | #169 4.8.0 | #174 4.8.1 | #176 4.9.0 | #182 4.11.0 | #198 In response to mockito/mockito#2860, a suggestion was made to use an `ArgumentCaptor` to capture the arguments and the `RETURNS_SELF` parameter for the builder. This PR makes that change, so we're now capturing arguments using the construct that is intended for that purpose. The mockito team has not committed to fixing this issue and may even be leaning toward not fixing it, since a more officially supported option exists to do what we're doing. I've applied these changes locally to #198 and confirmed that the tests complete as expected. ##### Motivation Allow newer versions of mockito ##### Context <!-- Are there any parts that you've intentionally left out-of-scope for a later PR to handle? --> <!-- Were there any alternative approaches you considered? What tradeoffs did you consider? --> #### Pull request checklist <!-- If a checklist item is not applicable to this change, write "n/a" in the checkbox --> - [n/a] Addresses an existing issue: - [n/a] Added/updated relevant unit test(s) - [x] Ran `./gradlew fastpass` from `AccessibilityInsightsForAndroidService` - [x] PR title _AND_ final merge commit title both start with a semantic tag (`fix:`, `chore:`, `feat(feature-name):`, `refactor:`).
We use mockito-inline in this test class. It works just great with mockito-inline version 4.6.1, but is broken with mockito-inline versions 4.7.0 and above. Specifically, when we try to mock out a method that accepts a gson
ExclusionStrategies
, the following Exception is thrown:Looking at the commits that went into version 4.7.0, it seems like #2664 and #2685 are the only commits that would have changed anything related to the stack trace shown above. My guess would be #2664, since the issue it was intended to fix (#2644) reported a stack trace that is almost identical to what we're seeing (even though we aren't using varargs).
Here's a stripped down class for testing purposes--it works on mockito-inline version 4.6.1, and fails on any version 4.7.0 or above:
check that
Note that some configuration are impossible to mock via Mockito
(same as any question on stackoverflow.com)
The text was updated successfully, but these errors were encountered: