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 import org.junit.runners.MethodSorters;
      9 
     10 /**
     11  * This class allows the user to choose the order of execution of the methods within a test class.
     12  *
     13  * <p>The default order of execution of JUnit tests within a class is deterministic but not predictable.
     14  * The order of execution is not guaranteed for Java 7 (and some previous versions), and can even change
     15  * from run to run, so the order of execution was changed to be deterministic (in JUnit 4.11)
     16  *
     17  * <p>It is recommended that test methods be written so that they are independent of the order that they are executed.
     18  * However, there may be a number of dependent tests either through error or by design.
     19  * This class allows the user to specify the order of execution of test methods.
     20  *
     21  * <p>For possibilities, see {@link MethodSorters}
     22  *
     23  * Here is an example:
     24  *
     25  * <pre>
     26  * &#064;FixMethodOrder(MethodSorters.NAME_ASCENDING)
     27  * public class MyTest {
     28  * }
     29  * </pre>
     30  *
     31  * @see org.junit.runners.MethodSorters
     32  * @since 4.11
     33  */
     34 @Retention(RetentionPolicy.RUNTIME)
     35 @Target({ElementType.TYPE})
     36 public @interface FixMethodOrder {
     37     /**
     38      * Optionally specify <code>value</code> to have the methods executed in a particular order
     39      */
     40     MethodSorters value() default MethodSorters.DEFAULT;
     41 }
     42