finally 블록 내부에서 수행되지 않는 JUnit 3의 super.tearDown() 메서드 호출을 보고합니다. super.tearDown()을 호출하기 전에 예외를 던질 수 있는 tearDown() 메서드에 다른 메서드 호출이 있을 경우 불일치와 누수가 발생할 수 있습니다.

예:


  public class AnotherTest extends CompanyTestCase {
    private Path path;

    @Override
    protected void setUp() throws Exception {
      super.setUp();
      path = Files.createTempFile("abcde", ".tmp");
    }

    @Override
    protected void tearDown() throws Exception {
      Files.delete(path);
      super.tearDown();
    }
  }

개선된 코드:


  public class AnotherTest extends CompanyTestCase {
    private Path path;

    @Override
    protected void setUp() throws Exception {
      super.setUp();
      path = Files.createTempFile("abcde", ".tmp");
    }

    @Override
    protected void tearDown() throws Exception {
      try {
        Files.delete(path);
      } finally {
        super.tearDown();
      }
    }
  }