@Test(expected=FileNotFoundException.class)
public void downloadExcelTest() {
stub(mockRoomService.getRoomByCode("ICU5")).toReturn(ICU5);
stub(mockRS.makeExcel(anyInt(), any(Room.class))).toReturn("FILE_DOES_NOT_EXIST.xls");
rc.downloadExcel(mockHTTP, 1, "ICU5", mockM);
}
所以我试图做一个junit测试来检查异常,但它似乎没有捕捉到异常。当我运行测试时,它说没有发生预期的异常,但控制台中出现以下错误。
java.io.FileNotFoundException: FILE_DOES_NOT_EXIST.xls (The system cannot find the file specified)
我的语法错误还是其他原因?