So I am trying to write a test case which covers a piece of code written inside catch block. This is how it goes:
I have two methods in class A.
class A{
public SomeReturnType m1()
{
try{
m2();
}catch(SomeException ex)
{
//handler code for SomeException (This is what I want to test).
}
}
public SomeReturnType m2() throws SomeException
{
//Some logic
}
}
I am wondering How can a force this exception when m2() is called from the unit test case of method m1()? Any solutions using Mockito or any other testing lib?
Aucun commentaire:
Enregistrer un commentaire