-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Mocking with explicit constructor fails with varargs parameter #2601
Comments
Hack to work around mockito/mockito#2601
I think the correct usage should be |
This: fails with:
I also tried with additional varargs values, and the exception thrown is similar. |
@jeff303 The actual problem with your test is that the A class should be public, and its constructor as well. Otherwise Mockito can't find the constructor. @TimvdLippe On the other hand, there is a "problem" with the
|
FYI @TimvdLippe, the test case in the description of this issue runs just find on the latest code (4.9.0). Looks like this issue can be closed. |
Thanks for confirming! |
This issue occurs even with Mockito |
@yashmayya Can you please open a PR to Mockito with the regression test so that we can confirm it still breaks and work towards fixing it? |
@TimvdLippe here's the PR with the regression test - #3081. Looks like it's a fairly rarely encountered issue because it only occurs when using the inline mock maker with the member accessor module on Java 9 and newer. |
Happy to take a look if we can merge in the test. |
Is there a better way to configure the member accessor plugin? The draft PR I pushed out to demonstrate the bug will cause every test to use |
We have a GitHub job matrix which should already be running at least that configuration. So maybe that file is not necessary and removing it will correctly fail only the job with the accessor. |
Thanks Tim, that makes sense. I've removed that file. |
Closing this per #3081 (comment) |
Consider the following test
On Temurin JDK 11, OS X,
mockito-core
4.4.0, this fails with:Changing the constructor param
c
to beAutoCloseable[]
makes it work. Is it possible to invoke the constructor with varargs in this case?The text was updated successfully, but these errors were encountered: