Skip to content
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

impossible to mock private methods with multiple arguments #309

Closed
johanhaleby opened this issue Jul 24, 2015 · 4 comments
Closed

impossible to mock private methods with multiple arguments #309

johanhaleby opened this issue Jul 24, 2015 · 4 comments

Comments

@johanhaleby
Copy link
Collaborator

From schiz...@gmail.com on November 07, 2010 00:46:45

When you try to mock private methods with multiple arguments via
any PowerMockito method using DefaultMethodExpectationSetup
you get
java.lang.IllegalArgumentException: wrong number of arguments

The problem is reproducible in 1.4.6 version.

It is caused by wrong arguments passed into method.invoke:
method.invoke(object, firstArgument, additionalArguments)
where an array of additional arguments is treated as single argument.
Instead it should be
method.invoke(object, firstAndAdditionalArgumentsArray)

See patch and test attached.

Mvh,
Stas Chizhov

Attachment: DefaultMethodExpectationSetupTest.java mockito-api-method-exp-setup-fix.diff

Original issue: http://code.google.com/p/powermock/issues/detail?id=289

@johanhaleby
Copy link
Collaborator Author

From johan.ha...@gmail.com on November 14, 2010 23:32:47

Hi,

Thanks for the report and a big thanks for the patch. I'll evaluate it when I get some time over.

/Johan

Status: Accepted
Labels: Milestone-Release1.4

@johanhaleby
Copy link
Collaborator Author

From johan.ha...@gmail.com on November 14, 2010 23:34:47

Labels: -Priority-Medium Priority-High

@johanhaleby
Copy link
Collaborator Author

From johan.ha...@gmail.com on November 16, 2010 12:01:10

Just applied the patch and it's now committed to trunk. Thank you very much for the help, really appreciated!

Status: Fixed

@johanhaleby
Copy link
Collaborator Author

From schiz...@gmail.com on November 16, 2010 14:31:18

Glad to help. You guys are doing great stuff :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant