-
Notifications
You must be signed in to change notification settings - Fork 11
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
Lambda in assertArg called twice #5
Comments
Thanks for your report and sorry for delay. It looks like that @raphw is it normal/required to have |
I forgot. The issue is reproduced in a (commented out) test in a separate branch: |
Hi, I think this is an implementation detail of Mockito and has nothing to do with Byte Buddy. The problem occures in the public void verify(VerificationData data) {
if(this.wantedCount > 0) {
MissingInvocationChecker numberOfInvocations = new MissingInvocationChecker();
numberOfInvocations.check(data.getAllInvocations(), data.getWanted()); // 1
}
NumberOfInvocationsChecker numberOfInvocations1 = new NumberOfInvocationsChecker();
numberOfInvocations1.check(data.getAllInvocations(), data.getWanted(), this.wantedCount); // 2
} The matcher is triggered once by (1) and once by (2). I assume that the original implementation did not consider that the matchers would trigger mutation. The easiest solution would be to fix this in Mockito, to be honest. A quicker fix would be to wrap the matchers to cache the result of the previous invocation. |
We have found an interesting issue, that seems to be caused by assertArg. For the following test
The lambda block gets invoked twice, being the IS in the second execution empty.
However if the same logic is done using a regular ArgumentCaptor, it works as expected (a single execution is done):
We could provide further context if needed.
Thank you very much.
The text was updated successfully, but these errors were encountered: