Annotation Interface TestClassOrder
@TestClassOrder is a type-level annotation that is used to configure
a ClassOrderer for the @Nested test classes of
the annotated test class.
If @TestClassOrder is not explicitly declared on a test class,
inherited from a parent class, declared on a test interface implemented by
a test class, or inherited from an enclosing
class, @Nested test classes will be ordered using a default
algorithm that is deterministic but intentionally nonobvious.
As an alternative to @TestClassOrder, a global ClassOrderer
can be configured for the entire test suite via the
"junit.jupiter.testclass.order.default" configuration parameter. See
the User Guide for details. Note, however, that a @TestClassOrder
declaration always overrides a global ClassOrderer.
Example Usage
The following demonstrates how to guarantee that @Nested test classes
are executed in the order specified via the @Order annotation.
@TestClassOrder(ClassOrderer.OrderAnnotation.class)
class OrderedNestedTests {
@Nested
@Order(1)
class PrimaryTests {
// @Test methods ...
}
@Nested
@Order(2)
class SecondaryTests {
// @Test methods ...
}
}- Since:
- 5.8
- See Also:
-
Required Element Summary
Required ElementsModifier and TypeRequired ElementDescriptionClass<? extends ClassOrderer> TheClassOrdererto use.
-
Element Details
-
value
-