001 package org.junit.runners; 002 003 import java.lang.reflect.Method; 004 import java.util.Comparator; 005 006 import org.junit.internal.MethodSorter; 007 008 /** 009 * Sort the methods into a specified execution order. 010 * Defines common {@link MethodSorter} implementations. 011 * 012 * @since 4.11 013 */ 014 public enum MethodSorters { 015 /** 016 * Sorts the test methods by the method name, in lexicographic order, 017 * with {@link Method#toString()} used as a tiebreaker 018 */ 019 NAME_ASCENDING(MethodSorter.NAME_ASCENDING), 020 021 /** 022 * Leaves the test methods in the order returned by the JVM. 023 * Note that the order from the JVM may vary from run to run 024 */ 025 JVM(null), 026 027 /** 028 * Sorts the test methods in a deterministic, but not predictable, order 029 */ 030 DEFAULT(MethodSorter.DEFAULT); 031 032 private final Comparator<Method> comparator; 033 034 private MethodSorters(Comparator<Method> comparator) { 035 this.comparator = comparator; 036 } 037 038 public Comparator<Method> getComparator() { 039 return comparator; 040 } 041 }