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 expensive external resources in a {@link org.junit.BeforeClass} method you need to release them
010 * after all the tests in the class have run. Annotating a <code>public static void</code> method
011 * 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>
012 * methods are guaranteed to run even if a {@link org.junit.BeforeClass} method throws an
013 * exception. The <code>&#064;AfterClass</code> methods declared in superclasses will be run after those of the current
014 * class, unless they are shadowed in the current class.
015 * <p>
016 * Here is a simple example:
017 * <pre>
018 * public class Example {
019 *    private static DatabaseConnection database;
020 *    &#064;BeforeClass public static void login() {
021 *          database= ...;
022 *    }
023 *    &#064;Test public void something() {
024 *          ...
025 *    }
026 *    &#064;Test public void somethingElse() {
027 *          ...
028 *    }
029 *    &#064;AfterClass public static void logout() {
030 *          database.logout();
031 *    }
032 * }
033 * </pre>
034 *
035 * @see org.junit.BeforeClass
036 * @see org.junit.Test
037 * @since 4.0
038 */
039@Retention(RetentionPolicy.RUNTIME)
040@Target(ElementType.METHOD)
041public @interface AfterClass {
042}