Handle Exception with Mockito
add this to your test method:
@Test(expected=DataException.class)
or use this :
then(caughtException()).isInstanceOf(DataException.class);
for a static-block there is no way other than try-catch.
Another way is to change DataException
to a RuntimeException
.
Don't use a static
block. Use a method tagged with @Before
instead, and tack throws Exception
onto its declaration.