1b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabotpackage org.junit;
2b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
3b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabotimport java.lang.annotation.ElementType;
4b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabotimport java.lang.annotation.Retention;
5b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabotimport java.lang.annotation.RetentionPolicy;
6b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabotimport java.lang.annotation.Target;
7b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
8b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot/**
9b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * <p>Sometimes several tests need to share computationally expensive setup
10b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * (like logging into a database). While this can compromise the independence of
11b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * tests, sometimes it is a necessary optimization. Annotating a <code>public static void</code> no-arg method
12b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * with <code>@BeforeClass</code> causes it to be run once before any of
13b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * the test methods in the class. The <code>@BeforeClass</code> methods of superclasses
14b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * will be run before those the current class.</p>
15b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot *
16b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * For example:
17b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * <pre>
18b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * public class Example {
19b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot *    &#064;BeforeClass public static void onlyOnce() {
20b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot *       ...
21b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot *    }
22b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot *    &#064;Test public void one() {
23b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot *       ...
24b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot *    }
25b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot *    &#064;Test public void two() {
26b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot *       ...
27b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot *    }
28b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * }
29b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * </pre>
30b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * @see org.junit.AfterClass
31b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot */
32b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot@Retention(RetentionPolicy.RUNTIME)
33b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot@Target(ElementType.METHOD)
34b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabotpublic @interface BeforeClass {
35b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot}
36