本文整理汇总了Java中org.junit.FixMethodOrder类的典型用法代码示例。如果您正苦于以下问题:Java FixMethodOrder类的具体用法?Java FixMethodOrder怎么用?Java FixMethodOrder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FixMethodOrder类属于org.junit包,在下文中一共展示了FixMethodOrder类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSorter
import org.junit.FixMethodOrder; //导入依赖的package包/类
private static Comparator<Method> getSorter(FixMethodOrder fixMethodOrder) {
if (fixMethodOrder == null) {
return DEFAULT;
}
return fixMethodOrder.value().getComparator();
}
示例2: getDeclaredMethods
import org.junit.FixMethodOrder; //导入依赖的package包/类
/**
* Gets declared methods of a class in a predictable order, unless @FixMethodOrder(MethodSorters.JVM) is specified.
*
* Using the JVM order is unwise since the Java platform does not
* specify any particular order, and in fact JDK 7 returns a more or less
* random order; well-written test code would not assume any order, but some
* does, and a predictable failure is better than a random failure on
* certain platforms. By default, uses an unspecified but deterministic order.
*
* @param clazz a class
* @return same as {@link Class#getDeclaredMethods} but sorted
* @see <a href="http://bugs.sun.com/view_bug.do?bug_id=7023180">JDK
* (non-)bug #7023180</a>
*/
public static Method[] getDeclaredMethods(Class<?> clazz) {
Comparator<Method> comparator = getSorter(clazz.getAnnotation(FixMethodOrder.class));
Method[] methods = clazz.getDeclaredMethods();
if (comparator != null) {
Arrays.sort(methods, comparator);
}
return methods;
}