本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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();
}
}
};
}
示例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);
}
}
}
}
};
}
示例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);
}
}
}
示例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);
}
示例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;
}