- java.lang.Object
-
- org.junit.jupiter.api.MethodOrderer.Random
-
- All Implemented Interfaces:
MethodOrderer
- Enclosing interface:
- MethodOrderer
public static class MethodOrderer.Random extends java.lang.Object implements MethodOrderer
MethodOrderer
that orders methods pseudo-randomly.Custom Seed
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 atCONFIG
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 theLauncher
API, build tools (e.g., Gradle and Maven), a JVM system property, or the JUnit Platform configuration file (i.e., a file namedjunit-platform.properties
in the root of the class path). Consult the User Guide for further information.- See Also:
RANDOM_SEED_PROPERTY_NAME
,Random
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.junit.jupiter.api.MethodOrderer
MethodOrderer.Alphanumeric, MethodOrderer.DisplayName, MethodOrderer.MethodName, MethodOrderer.OrderAnnotation, MethodOrderer.Random
-
-
Field Summary
Fields Modifier and Type Field Description private static long
DEFAULT_SEED
Default seed, which is generated during initialization of this class viaSystem.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 thisMethodOrderer
: "junit.jupiter.execution.order.random.seed"-
Fields inherited from interface org.junit.jupiter.api.MethodOrderer
DEFAULT_ORDER_PROPERTY_NAME
-
-
Constructor Summary
Constructors Constructor Description Random()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.util.Optional<java.lang.Long>
getCustomSeed(MethodOrdererContext context)
void
orderMethods(MethodOrdererContext context)
Order the methods encapsulated in the suppliedMethodOrdererContext
pseudo-randomly.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.junit.jupiter.api.MethodOrderer
getDefaultExecutionMode
-
-
-
-
Field Detail
-
logger
private static final Logger logger
-
DEFAULT_SEED
private static final long DEFAULT_SEED
Default seed, which is generated during initialization of this class viaSystem.nanoTime()
for reproducibility of tests.
-
RANDOM_SEED_PROPERTY_NAME
public static final java.lang.String RANDOM_SEED_PROPERTY_NAME
Property name used to set the random seed used by thisMethodOrderer
: "junit.jupiter.execution.order.random.seed"The same property is used by
ClassOrderer.Random
for consistency between the two random orderers.Supported Values
Supported values include any string that can be converted to a
Long
viaLong.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).- See Also:
ClassOrderer.Random
, Constant Field Values
-
-
Method Detail
-
orderMethods
public void orderMethods(MethodOrdererContext context)
Order the methods encapsulated in the suppliedMethodOrdererContext
pseudo-randomly.- Specified by:
orderMethods
in interfaceMethodOrderer
- Parameters:
context
- theMethodOrdererContext
containing the method descriptors to order; nevernull
- See Also:
MethodOrderer.getDefaultExecutionMode()
-
getCustomSeed
private java.util.Optional<java.lang.Long> getCustomSeed(MethodOrdererContext context)
-
-