Home | History | Annotate | Download | only in junit
      1 package org.junit;
      2 
      3 import java.lang.annotation.ElementType;
      4 import java.lang.annotation.Retention;
      5 import java.lang.annotation.RetentionPolicy;
      6 import java.lang.annotation.Target;
      7 
      8 /**
      9  * <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  *    &#064;BeforeClass public static void onlyOnce() {
     20  *       ...
     21  *    }
     22  *    &#064;Test public void one() {
     23  *       ...
     24  *    }
     25  *    &#064;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 }
     36