KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > junit > After


1 package org.junit;
2
3 import java.lang.annotation.ElementType JavaDoc;
4 import java.lang.annotation.Retention JavaDoc;
5 import java.lang.annotation.RetentionPolicy JavaDoc;
6 import java.lang.annotation.Target JavaDoc;
7
8 /**
9  * <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>&#064;After</code> causes that method to be run after the {@link org.junit.Test} method. All <code>&#064;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>&#064;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  * &#064;Before public void createOutputFile() {
21  * output= new File(...);
22  * }
23  * &#064;Test public void something() {
24  * ...
25  * }
26  * &#064;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 JavaDoc(RetentionPolicy.RUNTIME)
37 @Target JavaDoc(ElementType.METHOD)
38 public @interface After {
39 }
40
41
Popular Tags