Class MethodOrderer.Random
- 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
MethodOrdererthat orders methods pseudo-randomly and allows for concurrent execution by default.Custom Seed
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 thejunit.jupiter.execution.order.random.seedconfiguration parameter which can be supplied via theLauncherAPI, build tools (e.g., Gradle and Maven), a JVM system property, or the JUnit Platform configuration file (i.e., a file namedjunit-platform.propertiesin the root of the class path). Consult the User Guide for further information.- See Also:
getDefaultExecutionMode(),RANDOM_SEED_PROPERTY_NAME,Random
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.junit.jupiter.api.MethodOrderer
MethodOrderer.Alphanumeric, MethodOrderer.OrderAnnotation, MethodOrderer.Random
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringRANDOM_SEED_PROPERTY_NAMEProperty name used to set the random seed used by thisMethodOrderer: "junit.jupiter.execution.order.random.seed"
-
Constructor Summary
Constructors Constructor Description Random()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Optional<ExecutionMode>getDefaultExecutionMode()Get the defaultExecutionModefor the test class.voidorderMethods(MethodOrdererContext context)Order the methods encapsulated in the suppliedMethodOrdererContextpseudo-randomly.
-
-
-
Field Detail
-
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"Supported Values
Supported values include any string that can be converted to a
LongviaLong.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.- See Also:
- Constant Field Values
-
-
Method Detail
-
orderMethods
public void orderMethods(MethodOrdererContext context)
Order the methods encapsulated in the suppliedMethodOrdererContextpseudo-randomly.- Specified by:
orderMethodsin interfaceMethodOrderer- Parameters:
context- theMethodOrdererContextcontaining themethod descriptorsto order; nevernull- See Also:
MethodOrderer.getDefaultExecutionMode()
-
getDefaultExecutionMode
public java.util.Optional<ExecutionMode> getDefaultExecutionMode()
Get the defaultExecutionModefor the test class.If a custom seed has been specified, this method returns
SAME_THREADin order to ensure that the results are repeatable across executions of the test plan. Otherwise, this method returnsCONCURRENTto allow concurrent execution of randomly ordered methods by default.- Specified by:
getDefaultExecutionModein interfaceMethodOrderer- Returns:
SAME_THREADif a custom seed has been configured; otherwise,CONCURRENT- See Also:
MethodOrderer.orderMethods(MethodOrdererContext)
-
-