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