Mock implementation for void method

17. февраля 2017 JAVA, Test 0

When you want replace implementation method in test, you can use Mockito.

doAnswer(new Answer() {
public Object answer(InvocationOnMock invocation){
Object[] args = invocation.getArguments();
Mock mock = invocation.getMock();
return null;
}
}).when(mock).someMethodWithParameter(Matchers.any(),Matchers.any(User.class));