ClassOrderer
defines the API for ordering top-level test classes and
@Nested
test 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,
@Nested
test classes will be ordered relative to other @Nested
test classes sharing the same enclosing
class.
A ClassOrderer
can 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
@Nested
test classes via the @TestClassOrder
annotation.
JUnit Jupiter provides the following built-in ClassOrderer
implementations.
TestClassOrder
, ClassOrdererContext
, orderClasses(ClassOrdererContext)
, MethodOrderer
Modifier and Type | Class and Description |
---|---|
public static class | ClassOrderer.
|
public static class | ClassOrderer.
|
public static class | ClassOrderer.
|
public static class | ClassOrderer.
|
Modifier and Type | Field and Description |
---|---|
public static final String | DEFAULT_ORDER_PROPERTY_NAME
Property 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 |
Modifier and Type | Method and Description |
---|---|
public void | orderClasses(ClassOrdererContext context)
Order the classes encapsulated in the supplied |
DEFAULT_ORDER_PROPERTY_NAME | back to summary |
---|---|
public static final String DEFAULT_ORDER_PROPERTY_NAME Property name used to set the default class orderer class name: junit.jupiter.testclass.order.default Supported ValuesSupported values include fully qualified class names for types that
implement If not specified, test classes are not ordered unless test classes are
annotated with
|
orderClasses | back to summary |
---|---|
public void orderClasses(ClassOrdererContext context) Order the classes encapsulated in the supplied The classes to order or sort are made indirectly available via
For example, a simplified implementation of the public void orderClasses(ClassOrdererContext context) { Collections.shuffle(context.getClassDescriptors()); }
|
ClassOrderer
that sorts classes alphanumerically based on their
fully qualified names using String#compareTo(String)
.
Modifier and Type | Field and Description |
---|---|
private static final Comparator |
Access | Constructor and Description |
---|---|
public |
Modifier and Type | Method and Description |
---|---|
public void | orderClasses(ClassOrdererContext context)
Implements org. ClassOrdererContext alphanumerically based on their fully
qualified names.
|
comparator | back to summary |
---|---|
private static final Comparator<ClassDescriptor> comparator |
ClassName | back to summary |
---|---|
public ClassName() |
orderClasses | back to summary |
---|---|
public void orderClasses(ClassOrdererContext context) Implements org. Sort the classes encapsulated in the supplied
|
ClassOrderer
that sorts classes alphanumerically based on their
display names using String#compareTo(String)
Modifier and Type | Field and Description |
---|---|
private static final Comparator |
Access | Constructor and Description |
---|---|
public |
Modifier and Type | Method and Description |
---|---|
public void | orderClasses(ClassOrdererContext context)
Implements org. ClassOrdererContext alphanumerically based on their display
names.
|
comparator | back to summary |
---|---|
private static final Comparator<ClassDescriptor> comparator |
DisplayName | back to summary |
---|---|
public DisplayName() |
orderClasses | back to summary |
---|---|
public void orderClasses(ClassOrdererContext context) Implements org. Sort the classes encapsulated in the supplied
|
ClassOrderer
that sorts classes based on the @Order
annotation.
Any classes that are assigned the same order value will be sorted arbitrarily adjacent to each other.
Any classes not annotated with @Order
will be assigned the
default order value which will effectively cause them
to appear at the end of the sorted list, unless certain classes are assigned
an explicit order value greater than the default order value. Any classes
assigned an explicit order value greater than the default order value will
appear after non-annotated classes in the sorted list.
Access | Constructor and Description |
---|---|
public |
Modifier and Type | Method and Description |
---|---|
private static int | |
public void | orderClasses(ClassOrdererContext context)
Implements org. ClassOrdererContext based on the @Order
annotation.
|
OrderAnnotation | back to summary |
---|---|
public OrderAnnotation() |
getOrder | back to summary |
---|---|
private static int getOrder(ClassDescriptor descriptor) |
orderClasses | back to summary |
---|---|
public void orderClasses(ClassOrdererContext context) Implements org. Sort the classes encapsulated in the supplied
|
ClassOrderer
that orders classes pseudo-randomly.
By default, the random seed used for ordering classes is the
value returned by System#nanoTime()
during static initialization
of this class. In order to support repeatable builds, the value of the
default random seed is logged at CONFIG
level. In addition, a
custom seed (potentially the default seed from the previous test plan
execution) may be specified via the junit.jupiter.execution.order.random.seed
configuration parameter which can be supplied via the Launcher
API, build tools (e.g., Gradle and Maven), a JVM system property, or the JUnit
Platform configuration file (i.e., a file named junit-platform.properties
in the root of the class path). Consult the User Guide for further information.
Modifier and Type | Field and Description |
---|---|
private static final long | DEFAULT_SEED
Default seed, which is generated during initialization of this class
via |
private static final Logger | |
public static final String | RANDOM_SEED_PROPERTY_NAME
Property name used to set the random seed used by this
The same property is used by |
Access | Constructor and Description |
---|---|
public |
Modifier and Type | Method and Description |
---|---|
private Optional | |
public void | orderClasses(ClassOrdererContext context)
Implements org. ClassOrdererContext pseudo-randomly.
|
DEFAULT_SEED | back to summary |
---|---|
private static final long DEFAULT_SEED Default seed, which is generated during initialization of this class
via |
logger | back to summary |
---|---|
private static final Logger logger |
RANDOM_SEED_PROPERTY_NAME | back to summary |
---|---|
public static final String RANDOM_SEED_PROPERTY_NAME Property name used to set the random seed used by this
The same property is used by Supported ValuesSupported values include any string that can be converted to a
If not specified or if the specified value cannot be converted to
a
|
Random | back to summary |
---|---|
public Random() |
getCustomSeed | back to summary |
---|---|
private Optional |
orderClasses | back to summary |
---|---|
public void orderClasses(ClassOrdererContext context) Implements org. Order the classes encapsulated in the supplied
|