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