public static class MethodOrderer.Random extends Object implements MethodOrderer
MethodOrderer
that orders methods pseudo-randomly and allows for
concurrent execution by default.
By default, the random seed used for ordering methods is the
value returned by System.nanoTime()
. In order to produce repeatable
builds, a custom seed 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.
getDefaultExecutionMode()
,
RANDOM_SEED_PROPERTY_NAME
,
Random
MethodOrderer.Alphanumeric, MethodOrderer.OrderAnnotation, MethodOrderer.Random
Modifier and Type | Field and Description |
---|---|
static String |
RANDOM_SEED_PROPERTY_NAME
Property name used to set the random seed used by this
MethodOrderer : "junit.jupiter.execution.order.random.seed" |
Constructor and Description |
---|
Random() |
Modifier and Type | Method and Description |
---|---|
Optional<ExecutionMode> |
getDefaultExecutionMode()
Get the default
ExecutionMode for the test class. |
void |
orderMethods(MethodOrdererContext context)
Order the methods encapsulated in the supplied
MethodOrdererContext pseudo-randomly. |
public static final String RANDOM_SEED_PROPERTY_NAME
MethodOrderer
: "junit.jupiter.execution.order.random.seed"
Supported values include any string that can be converted to a
Long
via Long.valueOf(String)
.
If not specified or if the specified value cannot be converted to
a Long
, System.nanoTime()
will be used as the random
seed.
public void orderMethods(MethodOrdererContext context)
MethodOrdererContext
pseudo-randomly.orderMethods
in interface MethodOrderer
context
- the MethodOrdererContext
containing the
method descriptors
to order; never null
MethodOrderer.getDefaultExecutionMode()
public Optional<ExecutionMode> getDefaultExecutionMode()
ExecutionMode
for the test class.
If a custom seed has been specified, this method returns
SAME_THREAD
in order to ensure that
the results are repeatable across executions of the test plan.
Otherwise, this method returns CONCURRENT
to allow concurrent execution of randomly ordered methods
by default.
getDefaultExecutionMode
in interface MethodOrderer
SAME_THREAD
if a custom seed has been configured;
otherwise, CONCURRENT
MethodOrderer.orderMethods(MethodOrdererContext)
Copyright © 2021. All rights reserved.