KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > junit > AfterClass


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 expensive external resources in a {@link org.junit.BeforeClass} method you need to release them
10  * after all the tests in the class have run. Annotating a <code>public static void</code> method
11  * with <code>&#064;AfterClass</code> causes that method to be run after all the tests in the class have been run. All <code>&#064;AfterClass</code>
12  * methods are guaranteed to run even if a {@link org.junit.BeforeClass} method throws an
13  * exception. The <code>&#064;AfterClass</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  * DatabaseConnection database;
20  * &#064;BeforeClass public void login() {
21  * database= ...;
22  * }
23  * &#064;Test public void something() {
24  * ...
25  * }
26  * &#064;Test public void somethingElse() {
27  * ...
28  * }
29  * &#064;AfterClass public void logout() {
30  * database.logout();
31  * }
32  * }
33  * </pre>
34  *
35  * @see org.junit.BeforeClass
36  * @see org.junit.Test
37  */

38 @Retention JavaDoc(RetentionPolicy.RUNTIME)
39 @Target JavaDoc(ElementType.METHOD)
40 public @interface AfterClass {
41 }
42
Popular Tags