writer.close()
块内的方法会finally { }
在 Junit 断言错误上运行吗?
假设以下代码:
@Test
public void testWriter() {
try {
writer.open();
final List<MyBean> myBeans = new ArrayList<ProfileBean>();
/** Add 2 beans to the myBeans List here. **/
final int beansWritten = writer.writeBeans(myBeans);
// Say this assertion error below is triggered
org.junit.Assert.assertEquals("Wrong number of beans written.", -1, profilesWritten);
} finally {
writer.close(); // will this block run?
}
}
现在该finally()
块会像常规流程一样运行吗?