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


Java FrameworkMethod.getAnnotation方法代码示例

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


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

示例1: 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

示例2: computeTestMethods

import org.junit.runners.model.FrameworkMethod; //导入方法依赖的package包/类
@Override
protected List<FrameworkMethod> computeTestMethods() {
    final List<FrameworkMethod> testMethods = super.computeTestMethods();
    final List<FrameworkMethod> spockitoMethods = new ArrayList<>(testMethods.size());
    for (final FrameworkMethod testMethod : testMethods) {
        if (testMethod.getMethod().getParameterCount() == 0) {
            spockitoMethods.add(testMethod);
        } else {
            final Spockito.UseValueConverter useValueConverter = testMethod.getAnnotation(Spockito.UseValueConverter.class);
            final ValueConverter methodValueConverter = Spockito.getValueConverter(useValueConverter, defaultValueConverter);
            final UnrolledTestMethod spockitoTestMethod = new UnrolledTestMethod(testMethod.getMethod(), tableRow, methodValueConverter);
            spockitoMethods.add(spockitoTestMethod);
        }
    }
    return spockitoMethods;
}
 
开发者ID:tools4j,项目名称:spockito,代码行数:17,代码来源:SingleRowMultiTestRunner.java

示例3: 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

示例4: apply

import org.junit.runners.model.FrameworkMethod; //导入方法依赖的package包/类
@Override
public Statement apply(final Statement statement, final FrameworkMethod frameworkMethod, final Object o) {
  return new Statement() {
    @Override
    public void evaluate() throws Throwable {
      File testDir = null;
      TestDir testDirAnnotation = frameworkMethod.getAnnotation(TestDir.class);
      if (testDirAnnotation != null) {
        testDir = resetTestCaseDir(frameworkMethod.getName());
      }
      try {
        TEST_DIR_TL.set(testDir);
        statement.evaluate();
      } finally {
        TEST_DIR_TL.remove();
      }
    }
  };
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:TestDirHelper.java

示例5: apply

import org.junit.runners.model.FrameworkMethod; //导入方法依赖的package包/类
@Override
public Statement apply(final Statement statement, final FrameworkMethod frameworkMethod, final Object o) {
  return new Statement() {
    @Override
    public void evaluate() throws Throwable {
      TestJetty testJetty = frameworkMethod.getAnnotation(TestJetty.class);
      if (testJetty != null) {
        server = createJettyServer();
      }
      try {
        TEST_JETTY_TL.set(TestJettyHelper.this);
        statement.evaluate();
      } finally {
        TEST_JETTY_TL.remove();
        if (server != null && server.isRunning()) {
          try {
            server.stop();
          } catch (Exception ex) {
            throw new RuntimeException("Could not stop embedded servlet container, " + ex.getMessage(), ex);
          }
        }
      }
    }
  };
}
 
开发者ID:naver,项目名称:hadoop,代码行数:26,代码来源:TestJettyHelper.java

示例6: validateTestMethods

import org.junit.runners.model.FrameworkMethod; //导入方法依赖的package包/类
@Override
protected void validateTestMethods(final List<Throwable> errors) {
    final List<FrameworkMethod> methods = getTestClass().getAnnotatedMethods(Test.class);
    for (final FrameworkMethod method : methods) {
        final Spockito.Unroll unroll = method.getAnnotation(Spockito.Unroll.class);
        if (unroll == null) {
            method.validatePublicVoidNoArg(false, errors);
        } else {
            method.validatePublicVoid(false, errors);
            method.validateNoTypeParametersOnArgs(errors);
        }
    }
}
 
开发者ID:tools4j,项目名称:spockito,代码行数:14,代码来源:SingleTestMultiRowRunner.java

示例7: apply

import org.junit.runners.model.FrameworkMethod; //导入方法依赖的package包/类
@Override
public Statement apply(Statement statement, FrameworkMethod frameworkMethod, Object o) {
  TestHdfs testHdfsAnnotation = frameworkMethod.getAnnotation(TestHdfs.class);
  if (testHdfsAnnotation != null) {
    statement = new HdfsStatement(statement, frameworkMethod.getName());
  }
  return super.apply(statement, frameworkMethod, o);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:9,代码来源:TestHdfsHelper.java

示例8: getSampleName

import org.junit.runners.model.FrameworkMethod; //导入方法依赖的package包/类
private String getSampleName(FrameworkMethod method) {
    UsesSample annotation = method.getAnnotation(UsesSample.class);
    return annotation != null
        ? annotation.value()
        : defaultSampleName;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:7,代码来源:Sample.java


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