mercredi 4 mars 2015

How to avoid redundant catching exceptions of mocked methods which can throws exceptions according interface

I have following code in my unit test:



when(workspaceMock.getNamespaceRegistry()).thenReturn(namespaceRegistryMock);


method getNamespaceRegistry can throws IOException


In terms of java mentioned row is method call and I should to catch it.


But on another hand I understand that this method cannot throw exception because I set this method behaviour there. And it is looks redundant to catch exception here.


Can you clarify this situation and advise best practises?


Aucun commentaire:

Enregistrer un commentaire