Hi,
I am new to Power Mock. Can any one help me on mocking a void static method using doAnswer(). My requirement is when a static void method is called i should be able to capture the arguments and return a value.
I tried to do the following but is giving me an error,
PowerMockito.mockStatic(StaticClass.class);
doAnswer(new Answer(){
public Object answer(InvocationOnMock inv){
Object[] args = InvocationOnMock.getArguments;
//Do something
return string
}
}).when(StaticClass.class)staticVoidMethod();
I am not able to pass StaticClass.class but is expecting a mock object. And PowerMockito.mockStatic wont return any mock object.
Please help.