Interface ClassOrderer
-
- All Known Implementing Classes:
ClassOrderer.ClassName,ClassOrderer.DisplayName,ClassOrderer.OrderAnnotation,ClassOrderer.Random
@API(status=STABLE, since="5.10") public interface ClassOrdererClassOrdererdefines the API for ordering top-level test classes and@Nestedtest classes.In this context, the term "test class" refers to any class containing methods annotated with
@Test,@RepeatedTest,@ParameterizedTest,@TestFactory, or@TestTemplate.Top-level test classes will be ordered relative to each other; whereas,
@Nestedtest classes will be ordered relative to other@Nestedtest classes sharing the same enclosing class.A
ClassOrderercan be configured globally for the entire test suite via the "junit.jupiter.testclass.order.default" configuration parameter (see the User Guide for details) or locally for@Nestedtest classes via the@TestClassOrderannotation.Built-in Implementations
JUnit Jupiter provides the following built-in
ClassOrdererimplementations.- Since:
- 5.8
- See Also:
TestClassOrder,ClassOrdererContext,orderClasses(ClassOrdererContext),MethodOrderer
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classClassOrderer.ClassNameClassOrdererthat sorts classes alphanumerically based on their fully qualified names usingString.compareTo(String).static classClassOrderer.DisplayNameClassOrdererthat sorts classes alphanumerically based on their display names usingString.compareTo(String)static classClassOrderer.OrderAnnotationClassOrdererthat sorts classes based on the@Orderannotation.static classClassOrderer.RandomClassOrdererthat orders classes pseudo-randomly.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDEFAULT_ORDER_PROPERTY_NAMEProperty name used to set the default class orderer class name: "junit.jupiter.testclass.order.default"
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidorderClasses(ClassOrdererContext context)Order the classes encapsulated in the suppliedClassOrdererContext.
-
-
-
Field Detail
-
DEFAULT_ORDER_PROPERTY_NAME
@API(status=STABLE, since="5.9") static final java.lang.String DEFAULT_ORDER_PROPERTY_NAMEProperty name used to set the default class orderer class name: "junit.jupiter.testclass.order.default"Supported Values
Supported values include fully qualified class names for types that implement
ClassOrderer.If not specified, test classes are not ordered unless test classes are annotated with
@TestClassOrder.- Since:
- 5.8
- See Also:
- Constant Field Values
-
-
Method Detail
-
orderClasses
void orderClasses(ClassOrdererContext context)
Order the classes encapsulated in the suppliedClassOrdererContext.The classes to order or sort are made indirectly available via
ClassOrdererContext.getClassDescriptors(). Since this method has avoidreturn type, the list of class descriptors must be modified directly.For example, a simplified implementation of the
ClassOrderer.RandomClassOrderermight look like the following.public void orderClasses(ClassOrdererContext context) { Collections.shuffle(context.getClassDescriptors()); }- Parameters:
context- theClassOrdererContextcontaining the class descriptors to order; nevernull
-
-