@Target(value=TYPE) @Retention(value=RUNTIME) @Documented @Inherited @API(status=EXPERIMENTAL, since="5.4") public @interface TestMethodOrder
@TestMethodOrder is a type-level annotation that is used to configure
a MethodOrderer for 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 @TestMethodOrder is 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.
The following demonstrates how to guarantee that test methods are executed
in the order specified via the @Order annotation.
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
class OrderedTests {
@Test
@Order(1)
void nullValues() {}
@Test
@Order(2)
void emptyValues() {}
@Test
@Order(3)
void validValues() {}
}
MethodOrderer| Modifier and Type | Required Element and Description |
|---|---|
Class<? extends MethodOrderer> |
value
The
MethodOrderer to use. |
public abstract Class<? extends MethodOrderer> value
MethodOrderer to use.Copyright © 2024. All rights reserved.