Annotation Interface TestClassOrder

@Target(TYPE) @Retention(RUNTIME) @Documented @Inherited @API(status=EXPERIMENTAL, since="5.8") public @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 executed in arbitrary order.

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.

 class OrderedNestedTests {

     class PrimaryTests {
         // @Test methods ...

     class SecondaryTests {
         // @Test methods ...
See Also:
ClassOrderer, TestMethodOrder