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
008import org.junit.runners.MethodSorters;
009
010/**
011 * This class allows the user to choose the order of execution of the methods within a test class.
012 *
013 * <p>The default order of execution of JUnit tests within a class is deterministic but not predictable.
014 * The order of execution is not guaranteed for Java 7 (and some previous versions), and can even change
015 * from run to run, so the order of execution was changed to be deterministic (in JUnit 4.11)
016 *
017 * <p>It is recommended that test methods be written so that they are independent of the order that they are executed.
018 * However, there may be a number of dependent tests either through error or by design.
019 * This class allows the user to specify the order of execution of test methods.
020 *
021 * <p>For possibilities, see {@link MethodSorters}
022 *
023 * Here is an example:
024 *
025 * <pre>
026 * &#064;FixMethodOrder(MethodSorters.NAME_ASCENDING)
027 * public class MyTest {
028 * }
029 * </pre>
030 *
031 * @see org.junit.runners.MethodSorters
032 * @since 4.11
033 */
034@Retention(RetentionPolicy.RUNTIME)
035@Target({ElementType.TYPE})
036public @interface FixMethodOrder {
037    /**
038     * Optionally specify <code>value</code> to have the methods executed in a particular order
039     */
040    MethodSorters value() default MethodSorters.DEFAULT;
041}