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


Java FrameworkMethod类代码示例

本文整理汇总了Java中org.junit.runners.model.FrameworkMethod的典型用法代码示例。如果您正苦于以下问题:Java FrameworkMethod类的具体用法?Java FrameworkMethod怎么用?Java FrameworkMethod使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FrameworkMethod类属于org.junit.runners.model包,在下文中一共展示了FrameworkMethod类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: allPossible

import org.junit.runners.model.FrameworkMethod; //导入依赖的package包/类
Stream<Assignment> allPossible() throws Throwable {

        final List<FrameworkMethod> annotatedMethods = testClass.getAnnotatedMethods(DataProducer.class);


        Stream<Assignment> methodAssignments = Stream.empty();
        for (FrameworkMethod annotatedMethod : annotatedMethods) {
            final Type methodReturnType = getMethodGenericReturnType(annotatedMethod.getMethod());
            methodAssignments = Stream.concat(methodAssignments, methodToStreamOfResults(annotatedMethod)
                    .map(value -> new MethodResultAssignment(value, methodReturnType, annotatedMethod)));
        }

        final List<FrameworkField> annotatedFields = testClass.getAnnotatedFields(DataProducer.class);
        final Stream<Assignment> fieldsAssignments = annotatedFields.stream()
                .map(FieldAssignment::new);
        return Stream.concat(fieldsAssignments, methodAssignments);
    }
 
开发者ID:SeriyBg,项目名称:junit-easy-tools,代码行数:18,代码来源:PotentialAssignments.java

示例2: apply

import org.junit.runners.model.FrameworkMethod; //导入依赖的package包/类
public Statement apply(final Statement base, FrameworkMethod method, Object target) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            originalStdOut = System.out;
            originalStdErr = System.err;
            stdOutRouter.setOut(originalStdOut);
            stdErrRouter.setOut(originalStdErr);
            try {
                System.setOut(stdOutPrintStream);
                System.setErr(stdErrPrintStream);
                base.evaluate();
            } finally {
                System.setOut(originalStdOut);
                System.setErr(originalStdErr);
                stdOutRouter = null;
                stdErrRouter = null;
                stdOutPrintStream = null;
                stdErrPrintStream = null;
                stdoutContent = null;
                stderrContent = null;
            }
        }
    };
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:26,代码来源:RedirectStdOutAndErr.java

示例3: methodBlock

import org.junit.runners.model.FrameworkMethod; //导入依赖的package包/类
protected Statement methodBlock(FrameworkMethod method) {
    Object test;
    try {
        test = new ReflectiveCallable() {
            @Override
            protected Object runReflectiveCall() throws Throwable {
                return createTest();
            }
        }.run();
    } catch (Throwable e) {
        return new Fail(e);
    }

    Statement statement = methodInvoker(method, test);
    statement = possiblyExpectingExceptions(method, test, statement);
    statement = withPotentialTimeout(method, test, statement);
    statement = withBefores(method, test, statement);
    statement = withAfters(method, test, statement);
    statement = withRules(method, test, statement);
    return statement;
}
 
开发者ID:easymall,项目名称:easy-test,代码行数:22,代码来源:EasyJUnit4.java

示例4: computeTestMethods

import org.junit.runners.model.FrameworkMethod; //导入依赖的package包/类
@Override
protected List<FrameworkMethod> computeTestMethods() {
    List<FrameworkMethod> list = super.computeTestMethods();
    Collections.sort(list, new Comparator<FrameworkMethod>() {
        @Override
        public int compare(FrameworkMethod f1, FrameworkMethod f2) {
            Order o1 = f1.getAnnotation(Order.class);
            Order o2 = f2.getAnnotation(Order.class);

            if (o1 == null) {
                if (o2 != null) { // o1 == null, o2 != null
                    return 1;
                } else {  // o1 == null, o2 == null
                    return f1.getName().compareTo(f2.getName());
                }
            } else {
                if (o2 != null) {//o1 != null, o2 != null
                    return o1.value() - o2.value();
                } else { //o1 != null, o2 == null
                    return -1;
                }
            }
        }
    });
    return list;
}
 
开发者ID:altiplanogao,项目名称:io-comparison,代码行数:27,代码来源:OrderedRunner.java

示例5: computeTestMethods

import org.junit.runners.model.FrameworkMethod; //导入依赖的package包/类
@Override
protected List<FrameworkMethod> computeTestMethods() {
    List<FrameworkMethod> list = super.computeTestMethods();
    List<FrameworkMethod> copy = new ArrayList<>(list);
    Collections.sort(copy, new Comparator<FrameworkMethod>() {

        @Override
        public int compare(FrameworkMethod f1, FrameworkMethod f2) {
            Order o1 = f1.getAnnotation(Order.class);
            Order o2 = f2.getAnnotation(Order.class);

            if(o1 == null || o2 == null) {
                return -1;
            }

            return o1.order() - o2.order();
        }
    });

    return copy;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:22,代码来源:OrderedRunner.java

示例6: createRunners

import org.junit.runners.model.FrameworkMethod; //导入依赖的package包/类
private static List<Runner> createRunners(final Class<?> clazz) throws InitializationError {
    final ValueConverter defaultValueConverter = getDefaultValueConverter(clazz);
    final List<Runner> runners = new ArrayList<>();
    final Table classWideTable = classWideTableOrNull(clazz);
    if (classWideTable != null) {
        for (final TableRow row : classWideTable) {
            runners.add(new SingleRowMultiTestRunner(clazz, row, defaultValueConverter));
        }
    } else {
        for (final FrameworkMethod testMethod : new TestClass(clazz).getAnnotatedMethods(Test.class)) {
            final Spockito.UseValueConverter useValueConverter = testMethod.getAnnotation(Spockito.UseValueConverter.class);
            final ValueConverter methodValueConverter = Spockito.getValueConverter(useValueConverter, defaultValueConverter);
            runners.add(new SingleTestMultiRowRunner(clazz, testMethod, methodValueConverter));
        }
    }
    return runners;
}
 
开发者ID:tools4j,项目名称:spockito,代码行数:18,代码来源:Spockito.java

示例7: computeTestMethods

import org.junit.runners.model.FrameworkMethod; //导入依赖的package包/类
@Override
protected List<FrameworkMethod> computeTestMethods() {
    List<FrameworkMethod> list = super.computeTestMethods();
    List<FrameworkMethod> copy = new ArrayList<FrameworkMethod>(list);
    Collections.sort(copy, new Comparator<FrameworkMethod>() {

        @Override
        public int compare(FrameworkMethod f1, FrameworkMethod f2) {
            Order o1 = f1.getAnnotation(Order.class);
            Order o2 = f2.getAnnotation(Order.class);

            if (o1 == null || o2 == null) {
                return -1;
            }

            return o1.order() - o2.order();
        }
    });
    return copy;
}
 
开发者ID:airstep,项目名称:tubik,代码行数:21,代码来源:OrderedRunner.java

示例8: apply

import org.junit.runners.model.FrameworkMethod; //导入依赖的package包/类
/**
 * @see org.junit.rules.MethodRule#apply(org.junit.runners.model.Statement, org.junit.runners.model.FrameworkMethod, java.lang.Object)
 */
@Override
public Statement apply(final Statement base, final FrameworkMethod method, final Object target) {
  return new Statement() {
    @Override
    public void evaluate() throws Throwable {
      final List<Module> moduleWithTarget = new ArrayList<>(Arrays.asList(modules));
      if (target instanceof Module) {
        moduleWithTarget.add((Module) target);
      }
      Guice.createInjector(moduleWithTarget).injectMembers(target);
      try {
        base.evaluate();
      } finally {
        new ThreadSafeMockingProgress().reset();
      }
    }
  };
}
 
开发者ID:alfasoftware,项目名称:morf,代码行数:22,代码来源:InjectMembersRule.java

示例9: methodInvoker

import org.junit.runners.model.FrameworkMethod; //导入依赖的package包/类
@Override
protected Statement methodInvoker(final FrameworkMethod method, final Object test) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            PactFrameworkMethod pactFrameworkMethod = (PactFrameworkMethod) method;
            if (pactFrameworkMethod.shouldExclude()) {
                LOG.warn("Test has been excluded. Test will show as passed but was *NOT* run.");
                return;
            }
            if (pactFrameworkMethod.getWorkflow() != null) {
                setUpProviderState(test, pactFrameworkMethod.getWorkflow());
                pactFrameworkMethod.invokeExplosively(test, pactFrameworkMethod.getWorkflow().getInteractions());
            } else {
                setUpProviderState(test, pactFrameworkMethod.getInteraction());
                pactFrameworkMethod.invokeExplosively(test, Collections.singletonList(pactFrameworkMethod.getInteraction()));
            }
        }
    };
}
 
开发者ID:tyro,项目名称:pact-spring-mvc,代码行数:21,代码来源:PactTestRunner.java

示例10: BytecoderUnitTestRunner

import org.junit.runners.model.FrameworkMethod; //导入依赖的package包/类
public BytecoderUnitTestRunner(Class aClass) throws InitializationError {
    super(aClass);
    testClass = new TestClass(aClass);
    testMethods = new ArrayList<>();

    Method[] classMethods = aClass.getDeclaredMethods();
    for (Method classMethod : classMethods) {
        Class retClass = classMethod.getReturnType();
        int length = classMethod.getParameterTypes().length;
        int modifiers = classMethod.getModifiers();
        if (retClass == null || length != 0 || Modifier.isStatic(modifiers)
                || !Modifier.isPublic(modifiers) || Modifier.isInterface(modifiers)
                || Modifier.isAbstract(modifiers)) {
            continue;
        }
        String methodName = classMethod.getName();
        if (methodName.toUpperCase().startsWith("TEST")
                || classMethod.getAnnotation(Test.class) != null) {
            testMethods.add(new FrameworkMethod(classMethod));
        }
        if (classMethod.getAnnotation(Ignore.class) != null) {
            testMethods.remove(classMethod);
        }
    }
}
 
开发者ID:mirkosertic,项目名称:Bytecoder,代码行数:26,代码来源:BytecoderUnitTestRunner.java

示例11: computeTestMethods

import org.junit.runners.model.FrameworkMethod; //导入依赖的package包/类
@Override
protected List<FrameworkMethod> computeTestMethods() {
    final List<FrameworkMethod> unordered = super.computeTestMethods();
    List<FrameworkMethod> otherMethods = new ArrayList<>(unordered);
    List<FrameworkMethod> orderedMethods = new ArrayList<>();
    // extracting methods annotated ofRes Order
    for (int i = 0; i < otherMethods.size(); i++) {
        FrameworkMethod frameworkMethod = otherMethods.get(i);
        Order order = frameworkMethod.getAnnotation(Order.class);
        if (order != null) {
            orderedMethods.add(frameworkMethod);
            otherMethods.remove(i--);
        }
    }
    // sorting ordered methods
    Collections.sort(orderedMethods, new Comparator<FrameworkMethod>() {
        @Override
        public int compare(FrameworkMethod f1, FrameworkMethod f2) {
            return f1.getAnnotation(Order.class).value() -
                    f2.getAnnotation(Order.class).value();
        }
    });
    // appending other methods to ordered methods
    orderedMethods.addAll(otherMethods);
    return Collections.unmodifiableList(orderedMethods);
}
 
开发者ID:blipinsk,项目名称:cortado,代码行数:27,代码来源:OrderedJUnit4TestRunner.java

示例12: createTestObject

import org.junit.runners.model.FrameworkMethod; //导入依赖的package包/类
Object createTestObject() throws Exception {
    List<FrameworkMethod> annotatedMethods = testClass.getAnnotatedMethods(TestFactory.class);
    if (!annotatedMethods.isEmpty()) {
        Method factoryMethod = annotatedMethods.get(0).getMethod();
        validateFactoryMethod(factoryMethod);
        return factoryMethod.invoke(null);
    }
    return testClass.getOnlyConstructor().newInstance();
}
 
开发者ID:SeriyBg,项目名称:junit-easy-tools,代码行数:10,代码来源:TestObject.java

示例13: methodToStreamOfResults

import org.junit.runners.model.FrameworkMethod; //导入依赖的package包/类
private static Stream<?> methodToStreamOfResults(FrameworkMethod annotatedMethod) {
    try {
        return ((Collection<?>) annotatedMethod.invokeExplosively(null)).stream();
    } catch (Throwable throwable) {
        throw new IllegalArgumentException(throwable);
    }
}
 
开发者ID:SeriyBg,项目名称:junit-easy-tools,代码行数:8,代码来源:PotentialAssignments.java

示例14: validateTestMethods

import org.junit.runners.model.FrameworkMethod; //导入依赖的package包/类
@Override
protected void validateTestMethods(List<Throwable> errors) {
    List<FrameworkMethod> annotatedMethods = getTestClass().getAnnotatedMethods(Test.class);
    for (FrameworkMethod annotatedMethod : annotatedMethods) {
        annotatedMethod.validatePublicVoid(false, errors);
    }
}
 
开发者ID:SeriyBg,项目名称:junit-easy-tools,代码行数:8,代码来源:JUnitEasyTools.java

示例15: findArchRuleMethods

import org.junit.runners.model.FrameworkMethod; //导入依赖的package包/类
private Collection<ArchTestExecution> findArchRuleMethods() {
    List<ArchTestExecution> result = new ArrayList<>();
    for (FrameworkMethod testMethod : getTestClass().getAnnotatedMethods(ArchTest.class)) {
        result.add(new ArchTestMethodExecution(getTestClass().getJavaClass(), testMethod.getMethod(), false));
    }
    return result;
}
 
开发者ID:TNG,项目名称:ArchUnit,代码行数:8,代码来源:ArchUnitRunner.java


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