【发布时间】:2016-04-13 09:26:23
【问题描述】:
我的 Junit 测试函数有 try-catch 块。 在 catch 块中,我正在捕获异常以在 ExtentReport 中记录错误。 另外,我正在从 Apache ant 'junitreport' 生成 Junit 报告。 我的问题是,因为我在我的 catch 块中捕获异常,Junit 生成的结果不显示错误。 如何抛出异常(或其他方式)以注册 Junit 结果的异常。
代码如下:
try {
//Test code
} catch (Exception e) {
extentTest.log(LogStatus.ERROR, "Exception in clicking "); //For ExtentREport Logging
e.printStackTrace();
throw(new Exception(e.getMessage(), e)); //Expected Junit to capture error, but it is not happening
}
【问题讨论】: