I am getting problem with Mockito trying to call real method while stubbing. I assume this might be related to that method is inherited. This is component external to my system and can't do really much about it. But let's get to the code
AbstractRpcClient abstractRpcClient = mock(AbstractRpcClient.class);
doNothing().when(abstractRpcClient).callOnce(anyString(), anyVararg());
Since callOnce calls methods on some other objects I get NPE right in the second line. AbstractRpcClient inherits from another abstract class, but this class is package local, so I can't even cast it in my stubbing.
Is there anything I can do about it? How can I stub this method to do nothing or throw exception WITHOUT calling real method.
Do I have to extend this class in test and override method callOnce?
Aucun commentaire:
Enregistrer un commentaire