Package org.junit.runner.manipulation
Class Ordering
java.lang.Object
org.junit.runner.manipulation.Ordering
- Direct Known Subclasses:
Sorter
Reorders tests. An
Ordering
can reverse the order of tests, sort the
order or even shuffle the order.
In general you will not need to use a Ordering
directly.
Instead, use Request.orderWith(Ordering)
.
- Since:
- 4.13
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Context about the ordering being applied.static interface
Factory for creatingOrdering
instances. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Order the tests intarget
using this ordering.static Ordering
definedBy
(Class<? extends Ordering.Factory> factoryClass, Description annotatedTestClass) Creates anOrdering
from the given factory class.static Ordering
definedBy
(Ordering.Factory factory, Description annotatedTestClass) Creates anOrdering
from the given factory.private static String
getClassName
(Class<?> clazz) protected abstract List<Description>
orderItems
(Collection<Description> descriptions) Implemented by sub-classes to order the descriptions.static Ordering
shuffledBy
(Random random) (package private) boolean
Returnstrue
if this ordering could produce invalid results (i.e.
-
Field Details
-
CONSTRUCTOR_ERROR_FORMAT
- See Also:
-
-
Constructor Details
-
Ordering
public Ordering()
-
-
Method Details
-
shuffledBy
-
definedBy
public static Ordering definedBy(Class<? extends Ordering.Factory> factoryClass, Description annotatedTestClass) throws InvalidOrderingException Creates anOrdering
from the given factory class. The class must have a public no-arg constructor.- Parameters:
factoryClass
- class to use to create the orderingannotatedTestClass
- test class that is annotated withOrderWith
.- Throws:
InvalidOrderingException
- if the instance could not be created
-
definedBy
public static Ordering definedBy(Ordering.Factory factory, Description annotatedTestClass) throws InvalidOrderingException Creates anOrdering
from the given factory.- Parameters:
factory
- factory to use to create the orderingannotatedTestClass
- test class that is annotated withOrderWith
.- Throws:
InvalidOrderingException
- if the instance could not be created
-
getClassName
-
apply
Order the tests intarget
using this ordering.- Throws:
InvalidOrderingException
- if ordering does something invalid (like remove or add children)
-
validateOrderingIsCorrect
boolean validateOrderingIsCorrect()Returnstrue
if this ordering could produce invalid results (i.e. if it could add or remove values). -
orderItems
Implemented by sub-classes to order the descriptions.- Returns:
- descriptions in order
-