Package org.junit.runner.manipulation
Class Sorter
java.lang.Object
org.junit.runner.manipulation.Ordering
org.junit.runner.manipulation.Sorter
- All Implemented Interfaces:
Comparator<Description>
- Direct Known Subclasses:
Alphanumeric
A
Sorter
orders tests. In general you will not need
to use a Sorter
directly. Instead, use
Request.sortWith(Comparator)
.- Since:
- 4.0
-
Nested Class Summary
Nested classes/interfaces inherited from class org.junit.runner.manipulation.Ordering
Ordering.Context, Ordering.Factory
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Comparator<Description>
static final Sorter
NULL is aSorter
that leaves elements in an undefined order -
Constructor Summary
ConstructorsConstructorDescriptionSorter
(Comparator<Description> comparator) Creates aSorter
that usescomparator
to sort tests -
Method Summary
Modifier and TypeMethodDescriptionvoid
Sorts the tests intarget
usingcomparator
.int
compare
(Description o1, Description o2) protected final List<Description>
orderItems
(Collection<Description> descriptions) Implemented by sub-classes to order the descriptions.(package private) boolean
Returnstrue
if this ordering could produce invalid results (i.e.Methods inherited from class org.junit.runner.manipulation.Ordering
definedBy, definedBy, shuffledBy
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Field Details
-
NULL
NULL is aSorter
that leaves elements in an undefined order -
comparator
-
-
Constructor Details
-
Sorter
Creates aSorter
that usescomparator
to sort tests- Parameters:
comparator
- theComparator
to use when sorting tests- Since:
- 4.0
-
-
Method Details
-
apply
Sorts the tests intarget
usingcomparator
. -
compare
- Specified by:
compare
in interfaceComparator<Description>
-
orderItems
Implemented by sub-classes to order the descriptions.- Specified by:
orderItems
in classOrdering
- Returns:
- descriptions in order
- Since:
- 4.13
-
validateOrderingIsCorrect
boolean validateOrderingIsCorrect()Returnstrue
if this ordering could produce invalid results (i.e. if it could add or remove values).- Overrides:
validateOrderingIsCorrect
in classOrdering
- Since:
- 4.13
-