Top Description Methods
org.junit.jupiter.api

public @Interface TestClassOrder

extends Annotation
Annotations
@Target:TYPE
@Retention:RUNTIME
@Documented
@Inherited
@API
status:STABLE
since:5.10
Static Imports
org.apiguardian.api.API.Status.STABLE

@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
ClassOrderer, TestMethodOrder

Method Summary

Modifier and TypeMethod and Description
public Class<? extends ClassOrderer>
value()

The ClassOrderer to use.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

valueback to summary
public Class<? extends ClassOrderer> value()

The ClassOrderer to use.

See Also
ClassOrderer, ClassOrderer.ClassName, ClassOrderer.DisplayName, ClassOrderer.OrderAnnotation, ClassOrderer.Random