@Target(TYPE)
@Retention(RUNTIME)
@Documented
@Inherited
@API(status=STABLE,
since="5.10")
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.
@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
Modifier and TypeRequired ElementDescriptionClass
<? extends ClassOrderer> TheClassOrderer
to use.
-
Element Details
-
value
Class<? extends ClassOrderer> valueTheClassOrderer
to use.- See Also:
-