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/** 9b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * <p>If you allocate external resources in a {@link org.junit.Before} method you need to release them 10b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * after the test runs. Annotating a <code>public void</code> method 11b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * with <code>@After</code> causes that method to be run after the {@link org.junit.Test} method. All <code>@After</code> 12b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * methods are guaranteed to run even if a {@link org.junit.Before} or {@link org.junit.Test} method throws an 13b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * exception. The <code>@After</code> methods declared in superclasses will be run after those of the current 14b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * class.</p> 15b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * 16b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * Here is a simple example: 17b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot* <pre> 18b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * public class Example { 19b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * File output; 20b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * @Before public void createOutputFile() { 21b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * output= new File(...); 22b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * } 23b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * @Test public void something() { 24b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * ... 25b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * } 26b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * @After public void deleteOutputFile() { 27b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * output.delete(); 28b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * } 29b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * } 30b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * </pre> 31b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * 32b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * @see org.junit.Before 33b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * @see org.junit.Test 34b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot */ 35b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot 36b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot@Retention(RetentionPolicy.RUNTIME) 37b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot@Target(ElementType.METHOD) 38b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabotpublic @interface After { 39b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot} 40b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot 41