我需要测试以下代码:
try{
while((testBean = csvReader.read(TestBean.class,headers,getCellProcessors()))!=null){
System.out.println("no excpetion");
i=5;
}
}catch(SuperCsvException csvExc){
System.out.println("superCSV excpetion");
i=0;
}catch(Exception ex){
System.out.println("excpetion");
i=0;
}
Run Code Online (Sandbox Code Playgroud)
如何测试是否SuperCsvException被抛出和被捕获。
Run Code Online (Sandbox Code Playgroud)JUnit 4 supports this
@Test(expected=<YourExpectedException>.class)
public void testExceptionThrown() {
// call the method that throws exception
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11070 次 |
| 最近记录: |