1package org.junit; 2 3import java.lang.annotation.ElementType; 4import java.lang.annotation.Retention; 5import java.lang.annotation.RetentionPolicy; 6import java.lang.annotation.Target; 7 8/** 9 * <p>If you allocate expensive external resources in a {@link org.junit.BeforeClass} method you need to release them 10 * after all the tests in the class have run. Annotating a <code>public static void</code> method 11 * with <code>@AfterClass</code> causes that method to be run after all the tests in the class have been run. All <code>@AfterClass</code> 12 * methods are guaranteed to run even if a {@link org.junit.BeforeClass} method throws an 13 * exception. The <code>@AfterClass</code> methods declared in superclasses will be run after those of the current 14 * class.</p> 15 * 16 * Here is a simple example: 17* <pre> 18 * public class Example { 19 * private static DatabaseConnection database; 20 * @BeforeClass public static void login() { 21 * database= ...; 22 * } 23 * @Test public void something() { 24 * ... 25 * } 26 * @Test public void somethingElse() { 27 * ... 28 * } 29 * @AfterClass public static void logout() { 30 * database.logout(); 31 * } 32 * } 33 * </pre> 34 * 35 * @see org.junit.BeforeClass 36 * @see org.junit.Test 37 */ 38@Retention(RetentionPolicy.RUNTIME) 39@Target(ElementType.METHOD) 40public @interface AfterClass { 41} 42