我想在我的方法中测试异常处理.. 我试图doThrow()和willThrow()
given(landlineCodeDAO.findByCode(anyString())).willThrow(new Throwable("Exception occurred by TestCase"));
String resultResponse = ws.delete(memberUid, partitionUid, landlineCodeIn);
assertThat(resultResponse, is("{\"result\":\"failed\",\"result_code\":\"exception\"}"));
这是我的测试代码
和.....这是我的方法
catch (Throwable e) {
JFLogger.logger(getClass()).error("add() ", e);
try {
response.put("result", "failed");
response.put("result_code", "exception");
JFLogger.logger(getClass()).debug("{}", response.toString());
} catch (Throwable th) {
}
}
return response.toString();
此案例返回完毕。
但......
given(landlineCodeDAO.findByCode(anyString())).willThrow(new Throwable("Exception occurred by TestCase"));
String resultResponse = ws.delete(memberUid, partitionUid, landlineCodeIn);
assertThat(resultResponse, is("{\"result123123\":\"fail123123ed\",\"res123ult_code\":\"excepti123123on\"}"));
它也回来了......
我如何检查resultResponse?
我是年轻的韩国学生,我的英语不好...... 所以,请理解这个问题。