I want to do this:
when(GridLayout.class).addComponent(Matchers.any(Component.class), Matchers.anyInt(), Matchers.anyInt()).thenUseInstead(realLayout.addComponent(...));
Where GridLayout is my mock object and realLayout is a real Layout object.
I spotted doAnswer in the MockitoAPI (I think thats what I want?) however I am struggling to put it all together.
MockitoAPI 'doAnswer' example:
doAnswer(new Answer() {
public Object answer(InvocationOnMock invocation) {
Object[] args = invocation.getArguments();
Mock mock = invocation.getMock();
return null;
}})
.when(mock).someMethod();
Can anyone help?
Aucun commentaire:
Enregistrer un commentaire