1 package org.junit.runners;
2
3 import java.lang.reflect.Method;
4 import java.util.Comparator;
5
6 import org.junit.internal.MethodSorter;
7
8 /**
9 * Sort the methods into a specified execution order.
10 * Defines common {@link MethodSorter} implementations.
11 *
12 * @since 4.11
13 */
14 public enum MethodSorters {
15 /**
16 * Sorts the test methods by the method name, in lexicographic order,
17 * with {@link Method#toString()} used as a tiebreaker
18 */
19 NAME_ASCENDING(MethodSorter.NAME_ASCENDING),
20
21 /**
22 * Leaves the test methods in the order returned by the JVM.
23 * Note that the order from the JVM may vary from run to run
24 */
25 JVM(null),
26
27 /**
28 * Sorts the test methods in a deterministic, but not predictable, order
29 */
30 DEFAULT(MethodSorter.DEFAULT);
31
32 private final Comparator<Method> comparator;
33
34 private MethodSorters(Comparator<Method> comparator) {
35 this.comparator = comparator;
36 }
37
38 public Comparator<Method> getComparator() {
39 return comparator;
40 }
41 }