01: package org.junit;
02:
03: import java.lang.annotation.ElementType;
04: import java.lang.annotation.Retention;
05: import java.lang.annotation.RetentionPolicy;
06: import java.lang.annotation.Target;
07:
08: /**
09: * <p>If you allocate external resources in a {@link org.junit.Before} method you need to release them
10: * after the test runs. Annotating a <code>public void</code> method
11: * with <code>@After</code> causes that method to be run after the {@link org.junit.Test} method. All <code>@After</code>
12: * methods are guaranteed to run even if a {@link org.junit.Before} or {@link org.junit.Test} method throws an
13: * exception. The <code>@After</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: * File output;
20: * @Before public void createOutputFile() {
21: * output= new File(...);
22: * }
23: * @Test public void something() {
24: * ...
25: * }
26: * @After public void deleteOutputFile() {
27: * output.delete();
28: * }
29: * }
30: * </pre>
31: *
32: * @see org.junit.Before
33: * @see org.junit.Test
34: */
35:
36: @Retention(RetentionPolicy.RUNTIME)
37: @Target(ElementType.METHOD)
38: public @interface After {
39: }
|