001 package org.junit; 002 003 import java.lang.annotation.ElementType; 004 import java.lang.annotation.Retention; 005 import java.lang.annotation.RetentionPolicy; 006 import java.lang.annotation.Target; 007 008 /** 009 * If you allocate expensive external resources in a {@link org.junit.BeforeClass} method you need to release them 010 * after all the tests in the class have run. Annotating a <code>public static void</code> method 011 * with <code>@AfterClass</code> causes that method to be run after all the tests in the class have been run. All <code>@AfterClass</code> 012 * methods are guaranteed to run even if a {@link org.junit.BeforeClass} method throws an 013 * exception. The <code>@AfterClass</code> methods declared in superclasses will be run after those of the current 014 * class, unless they are shadowed in the current class. 015 * <p> 016 * Here is a simple example: 017 * <pre> 018 * public class Example { 019 * private static DatabaseConnection database; 020 * @BeforeClass public static void login() { 021 * database= ...; 022 * } 023 * @Test public void something() { 024 * ... 025 * } 026 * @Test public void somethingElse() { 027 * ... 028 * } 029 * @AfterClass public static void logout() { 030 * database.logout(); 031 * } 032 * } 033 * </pre> 034 * 035 * @see org.junit.BeforeClass 036 * @see org.junit.Test 037 * @since 4.0 038 */ 039 @Retention(RetentionPolicy.RUNTIME) 040 @Target(ElementType.METHOD) 041 public @interface AfterClass { 042 }