java - Handle Exception with Mockito -
I am using In the case of my test This returns an error, to handle or use it: There is no way other than trying-hold for a static-block. One way to change the runtime exception to DataException. mokita in my unit test. I have a method
public status getResponse (request requset) throws DataException {}
DataException My definition is that the exception Inherited from the class.
static {when (process.getResponse (any (Request.class))). Then return (new situation ("success")); }
unchecked exception: DataException
Mockito The method is to add this problem to your test method:
@Test (expected = DataException.class)
then (caught exception ()). isInstanceOf (DataException.class);
Comments
Post a Comment