当前位置: 首页>>代码示例>>Java>>正文


Java FixMethodOrder类代码示例

本文整理汇总了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();
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:8,代码来源:MethodSorter.java

示例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;
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:25,代码来源:MethodSorter.java


注:本文中的org.junit.FixMethodOrder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。