Why won't this Expect Exception Junit Test Work?

前端 未结 2 2011
灰色年华
灰色年华 2021-01-27 14:06

This is my test so far:

@Test(expected = FileNotFoundException.class)
public void testExpectedException() {
    UserDataObject u = new UserDataObject(\"rob123\",         


        
2条回答
  •  南方客
    南方客 (楼主)
    2021-01-27 14:35

    The issue is that your verifyUser(UserDataObject u, String filename) method catches both exceptions FileNotFoundException and IOException and hence it is not propagated to your test method.

提交回复
热议问题