diff --git a/src/test/java/org/junit/internal/MethodSorterTest.java b/src/test/java/org/junit/internal/MethodSorterTest.java index 1934fa2d7e27..73182352ccd1 100644 --- a/src/test/java/org/junit/internal/MethodSorterTest.java +++ b/src/test/java/org/junit/internal/MethodSorterTest.java @@ -6,6 +6,7 @@ import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; +import java.util.Comparator; import java.util.List; import org.junit.FixMethodOrder; @@ -147,6 +148,21 @@ void epsilon() { public void testJvmMethodSorter() { Method[] fromJvmWithSynthetics = DummySortJvm.class.getDeclaredMethods(); Method[] sorted = MethodSorter.getDeclaredMethods(DummySortJvm.class); + + Comparator methodComparator = new Comparator() { + @Override + public int compare(Method m1, Method m2) { + int nameComparison = m1.getName().compareTo(m2.getName()); + if (nameComparison != 0) { + return nameComparison; + } + return m1.toString().compareTo(m2.toString()); + } + }; + + Arrays.sort(fromJvmWithSynthetics, methodComparator); + Arrays.sort(sorted, methodComparator); + assertArrayEquals(fromJvmWithSynthetics, sorted); }