Mock implementation for void method
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));