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