程序包 org.junit

注释类型 FixMethodOrder


  • @Retention(RUNTIME)
    @Target(TYPE)
    public @interface FixMethodOrder
    This class allows the user to choose the order of execution of the methods within a test class.

    The default order of execution of JUnit tests within a class is deterministic but not predictable. The order of execution is not guaranteed for Java 7 (and some previous versions), and can even change from run to run, so the order of execution was changed to be deterministic (in JUnit 4.11)

    It is recommended that test methods be written so that they are independent of the order that they are executed. However, there may be a number of dependent tests either through error or by design. This class allows the user to specify the order of execution of test methods.

    For possibilities, see MethodSorters Here is an example:

     @FixMethodOrder(MethodSorters.NAME_ASCENDING)
     public class MyTest {
     }
     
    从以下版本开始:
    4.11
    另请参阅:
    MethodSorters
    • 可选元素概要

      可选元素 
      修饰符和类型可选元素说明
      MethodSortersvalue
      Optionally specify value to have the methods executed in a particular order
    • 元素详细资料

      • value

        MethodSorters value
        Optionally specify value to have the methods executed in a particular order
        默认值:
        org.junit.runners.MethodSorters.DEFAULT