-
Notifications
You must be signed in to change notification settings - Fork 202
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
Mockito 5.0 breaks vararg argument capture in Kotlin #474
Comments
Moved from mockito/mockito#2878 |
If anybody would like to stab at this, I am happy to review a PR with a regression test + fix. |
I see that the PR 2807 got merged, which looks like it's trying to fix this. Any estimate on when this will be available? |
@kschults I think 2807 is the PR that introduced the problems for Kotlin (while it works fine for Java). |
Oh, I see, I misread the timeline. Thanks. |
Come up with this workaround. Honestly speaking, I don't really understand why it works.
|
Fixed in #482 |
@TimvdLippe @lukas-krecan What about the vararg argument capturing for Kotlin? |
The original code still needs to be fixed - even it fails with a similar error. Please re-open. |
Yes, it's indeed still broken |
@TimvdLippe please reopen |
Instead of |
@TimvdLippe The problem is not in the mocking but in the line with argument capturing. Or I understood your comment wrongly. |
To perhaps clarify the issue, you can capture varargs if you know how many are being passed in, e.g. I'm pretty sure the example in the OP could be fixed with
Which will capture both arguments passed in for that instance, in the same way the previous behavior seemed to work. The problem is that there is now no way to capture all varargs regardless of how many are actually passed in, which is an annoyance if you're trying to write e.g. a helper method that will get used in multiple situations that result in differing numbers of arguments that need to be captured. |
Yeah. We've ended up with places where we have to write:
It works, but it's a little silly. |
This seems to be working. Please check the tests if they reflect your use-case. |
@lukas-krecan, they do reflect our case! |
This is awesome to see. When do you expect a release containing this fix to be available? |
5.1.0 should be published later today |
Hence issue was wrongly put on the mockito project.
Have code:
Write tests:
Run test and observe:
The text was updated successfully, but these errors were encountered: