MethodComparator implements Comparator<Method> { @Override public int compare(Method o1, Method o2) { int res = o1.getParameterTypes().length - o2.getParameterTypes().length; if (res == 0) { return -1; } return res; }  @Override int compare(Method o1, Method o2);  }
@Test public void testCompareM1afterM2() { System.out.println("compare"); Method m1 = getMethodByName("methodA"); Method m2 = getMethodByName("methodC"); int result = instance.compare(m1, m2); assertThat(result).isEqualTo(1); }
@Test public void testCompareM1equalM2() { System.out.println("compare"); Method m1 = getMethodByName("methodA"); Method m2 = getMethodByName("methodB"); int result = instance.compare(m1, m2); assertThat(result).isEqualTo(-1); }
@Test public void testCompareM1beforeM2() { System.out.println("compare"); Method m1 = getMethodByName("methodC"); Method m2 = getMethodByName("methodB"); int result = instance.compare(m1, m2); assertThat(result).isEqualTo(-1); }