public static class MethodOrderer.Random extends java.lang.Object implements MethodOrderer
MethodOrderer
that orders methods pseudo-randomly.
By default, the random seed used for ordering methods 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 INFO
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.
RANDOM_SEED_PROPERTY_NAME
,
Random
MethodOrderer.Alphanumeric, MethodOrderer.OrderAnnotation, MethodOrderer.Random
Modifier and Type | Field and Description |
---|---|
private static long |
DEFAULT_SEED
Default seed, which is generated during initialization of this class
via
System.nanoTime() for reproducibility of tests. |
private static Logger |
logger |
static java.lang.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 |
---|---|
private java.util.Optional<java.lang.Long> |
getCustomSeed(MethodOrdererContext context) |
void |
orderMethods(MethodOrdererContext context)
Order the methods encapsulated in the supplied
MethodOrdererContext pseudo-randomly. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getDefaultExecutionMode
private static final Logger logger
private static final long DEFAULT_SEED
System.nanoTime()
for reproducibility of tests.public static final java.lang.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
, the default random seed will be used (see the
class-level Javadoc for details).
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()
private java.util.Optional<java.lang.Long> getCustomSeed(MethodOrdererContext context)