You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What steps will reproduce the problem? 1. Run the test class attached. Error will be thrown. What is the expected output? What do you see instead? String "mocked" in the console but I got an error. What version of the product are you using? On what operating system? R: powermock-mockito-1.5.1-full.jar, jdk7. Please provide any additional information below. The problem is on line 37 of the class DefaultPrivatelyExpectedArguments.
And the method call:
method.invoke(mock, firstArgument, additionalArguments);
If I call the method withArguments with more than two arguments, held that: the call to the invoke method will always be considered to have only two parameters. One being the first argument and the other an array with the other arguments.
Solution: change the method signature to DefaultPrivatelyExpectedArguments#withArguments(Object... arguments) or create a temporary array for the arguments,
From ande.brb on October 10, 2013 15:20:40
What steps will reproduce the problem? 1. Run the test class attached. Error will be thrown. What is the expected output? What do you see instead? String "mocked" in the console but I got an error. What version of the product are you using? On what operating system? R: powermock-mockito-1.5.1-full.jar, jdk7. Please provide any additional information below. The problem is on line 37 of the class DefaultPrivatelyExpectedArguments.
Note the declaration of the following methods:
DefaultPrivatelyExpectedArguments#withArguments(Object firstArgument, Object... additionalArguments)
Method#invoke(Object obj, Object... args)
And the method call:
method.invoke(mock, firstArgument, additionalArguments);
If I call the method withArguments with more than two arguments, held that: the call to the invoke method will always be considered to have only two parameters. One being the first argument and the other an array with the other arguments.
Solution: change the method signature to DefaultPrivatelyExpectedArguments#withArguments(Object... arguments) or create a temporary array for the arguments,
Object[] array = new Object[additionalArguments.length + 1];
array[0] = firstArgument;
System.arraycopy(additionalArguments, 0, array, 1, additionalArguments.length);
method.invoke(mock, array);
Attachment: PowerMockitoIssue.java
Original issue: http://code.google.com/p/powermock/issues/detail?id=465
The text was updated successfully, but these errors were encountered: