17

ブロック内の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()ブロックは通常のフローと同じように実行されますか?

4

2 に答える 2