本文整理汇总了Java中org.junit.internal.runners.statements.InvokeMethod类的典型用法代码示例。如果您正苦于以下问题:Java InvokeMethod类的具体用法?Java InvokeMethod怎么用?Java InvokeMethod使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InvokeMethod类属于org.junit.internal.runners.statements包,在下文中一共展示了InvokeMethod类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: methodInvoker
import org.junit.internal.runners.statements.InvokeMethod; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
protected Statement methodInvoker(final FrameworkMethod method, final Object test) {
return new InvokeMethod(method, test) {
@Override
// CHECKSTYLE:CHECK-OFF IllegalThrow // inherited JUnit throw style
public void evaluate() throws Throwable {
// CHECKSTYLE:CHECK-ON IllegalThrow
try {
super.evaluate();
// CHECKSTYLE:CHECK-OFF IllegalCatch // catching in order to act upon but then throwing the exception again
} catch (final Throwable throwable) {
// CHECKSTYLE:CHECK-ON IllegalCatch
testRunRecording.methodInvokeFailure(throwable);
throw throwable;
}
}
};
}
示例2: runChild
import org.junit.internal.runners.statements.InvokeMethod; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected void runChild(final FrameworkMethod method, final RunNotifier notifier) {
final Description description = describeChild(method);
if (isIgnored(method)) {
notifier.fireTestIgnored(description);
} else {
final InvokeMethod statement = (InvokeMethod) methodBlock(method);
final Object test = ReflexUtils.getFieldValue(statement, "target");
final ConditionChecker<?> checker =
ConditionCheckerEngine.detectFailedChecker(test, method);
if (checker != null) {
notifier.fireTestIgnored(description);
} else {
runLeaf(statement, description, notifier);
}
}
}
示例3: runSingleTest
import org.junit.internal.runners.statements.InvokeMethod; //导入依赖的package包/类
private void runSingleTest(FrameworkMethod method, RunNotifier notifier) throws IllegalAccessException,
InvocationTargetException, InstantiationException {
Object test = getTestClass().getOnlyConstructor().newInstance();
Statement statement = new InvokeMethod(method, test);
Description description = describeChild(method);
notifier.fireTestStarted(description);
try {
statement.evaluate();
if (method.getName().endsWith("MustFail")) {
notifier.fireTestFailure(new Failure(description, new RuntimeException("Test didn't fail.")));
}
} catch (Throwable e) {
if (!method.getName().endsWith("MustFail")) {
notifier.fireTestFailure(new Failure(description, e));
}
} finally {
notifier.fireTestFinished(description);
}
}
示例4: runRule
import org.junit.internal.runners.statements.InvokeMethod; //导入依赖的package包/类
public static void runRule(TestRule rule, Object target, String methodName) {
Class<?> clazz = target.getClass();
Method method = TestUtils.getMethod(clazz, methodName);
Description description = Description.createTestDescription(clazz, method.getName(), method.getDeclaredAnnotations());
try {
InvokeMethod invokeMethod = new InvokeMethod(new FrameworkMethod(method), target);
rule.apply(invokeMethod, description).evaluate();
} catch (Throwable throwable) {
logger.warning(Arrays.toString(throwable.getStackTrace()));
}
}
示例5: methodBlock
import org.junit.internal.runners.statements.InvokeMethod; //导入依赖的package包/类
private Statement methodBlock(FrameworkMethod method) {
Object testObject;
try {
testObject = new ReflectiveCallable() {
@Override
protected Object runReflectiveCall() throws Throwable {
return getTestClass().getOnlyConstructor().newInstance(new Object[0]);
}
}.run();
} catch (Throwable throwable) {
return new Fail(throwable);
}
return new InvokeMethod(method, testObject);
}
示例6: methodInvoker
import org.junit.internal.runners.statements.InvokeMethod; //导入依赖的package包/类
/**
* Returns a {@link org.junit.runners.model.Statement} that invokes {@code method} on {@code test}
*/
protected Statement methodInvoker(FrameworkMethod method, Object test) {
return new InvokeMethod(method, test);
}
示例7: methodInvoker
import org.junit.internal.runners.statements.InvokeMethod; //导入依赖的package包/类
/**
* Returns a {@link Statement} that invokes {@code method} on {@code test}
*/
protected Statement methodInvoker(FrameworkMethod method, Object test) {
return new InvokeMethod(method, test);
}
示例8: methodInvoker
import org.junit.internal.runners.statements.InvokeMethod; //导入依赖的package包/类
/**
* Returns a {@link Statement} that invokes {@code method} on {@code test}
*/
@Override
protected Statement methodInvoker(FrameworkMethod method, Object test) {
return new InvokeMethod(convert(method), test);
}
示例9: buildStatement
import org.junit.internal.runners.statements.InvokeMethod; //导入依赖的package包/类
protected Statement buildStatement(final TestClass testClass, final FrameworkMethod method, final Object target,
final Description description, final RunNotifier notifier) {
return new InvokeMethod(method, target);
}
示例10: methodInvoker
import org.junit.internal.runners.statements.InvokeMethod; //导入依赖的package包/类
@Override
protected Statement methodInvoker(FrameworkMethod method, Object test) {
ComplianceSuiteTest eTest = (ComplianceSuiteTest) test;
eTest.setExecutor(executor);
return new InvokeMethod(method, test);
}