Annotation Type TestMethodOrder
-
@Target(TYPE) @Retention(RUNTIME) @Documented @Inherited @API(status=STABLE, since="5.7") public @interface TestMethodOrder@TestMethodOrderis a type-level annotation that is used to configure aMethodOrdererfor the test methods of the annotated test class or test interface.In this context, the term "test method" refers to any method annotated with
@Test,@RepeatedTest,@ParameterizedTest,@TestFactory, or@TestTemplate.If
@TestMethodOrderis not explicitly declared on a test class, inherited from a parent class, or declared on a test interface implemented by a test class, test methods will be ordered using a default algorithm that is deterministic but intentionally nonobvious.As an alternative to
@TestMethodOrder, a globalMethodOrderercan be configured for the entire test suite via the "junit.jupiter.testmethod.order.default" configuration parameter. See the User Guide for details. Note, however, that a@TestClassOrderdeclaration always overrides a globalClassOrderer.Example Usage
The following demonstrates how to guarantee that test methods are executed in the order specified via the
@Orderannotation.@TestMethodOrder(MethodOrderer.OrderAnnotation.class) class OrderedTests { @Test @Order(1) void nullValues() {} @Test @Order(2) void emptyValues() {} @Test @Order(3) void validValues() {} }Parallel Execution
Using a
MethodOrdererdisables parallel execution unless the test class or test method is annotated with@Execution(CONCURRENT).- Since:
- 5.4
- See Also:
MethodOrderer,TestClassOrder
-
-
Required Element Summary
Required Elements Modifier and Type Required Element Description java.lang.Class<? extends MethodOrderer>valueTheMethodOrdererto use.
-
-
-
Element Detail
-
value
java.lang.Class<? extends MethodOrderer> value
TheMethodOrdererto use.
-
-