finally { }
블록 내의 writer.close()
메서드가 Junit 어설 션 오류에서 실행됩니까? 이제Junit 테스트가 'try'블록의 어설 션 오류를 throw 한 후에도 'finally'블록이 실행됩니까?
@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()
블록 실행 :
예, 실행해야합니다. –
가능한 복제본 [이해와 함께 마침내 시도해보기] (http://stackoverflow.com/questions/26658853/understanding-try-catch-finally-with-return) – StackFlowed
죄송합니다, 고전적인 시도를 이해하고 마지막으로 흐름을 이해합니다. . 이 질문은 관련 Junit 테스트 흐름과는 다릅니다. –