I'm using a very limited set of reflection in this piece of code:
public NetworkClient createNetworkClient() {
try {
return (NetworkClient) getNetworkClientClass().getConstructors()[0].newInstance();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
return null;
}
How can I test that newInstance()
throw an InvocationTargetException
(and the other exception) ?
I'm currently using Mockito and Hamcrest for the rest of the UT.
Aucun commentaire:
Enregistrer un commentaire