use of org.junit.internal.runners.statements.Fail in project android by JetBrains.
the class GuiTestRunner method methodBlock.
@Override
protected Statement methodBlock(FrameworkMethod method) {
if (GraphicsEnvironment.isHeadless()) {
// checked first because IdeTestApplication.getInstance below (indirectly) throws an AWTException in a headless environment
return falseAssumption("headless environment");
}
Method methodFromClassLoader;
try {
ClassLoader ideClassLoader = IdeTestApplication.getInstance().getIdeClassLoader();
Thread.currentThread().setContextClassLoader(ideClassLoader);
myTestClass = new TestClass(ideClassLoader.loadClass(getTestClass().getJavaClass().getName()));
methodFromClassLoader = myTestClass.getJavaClass().getMethod(method.getName());
} catch (Exception e) {
return new Fail(e);
}
return super.methodBlock(new FrameworkMethod(methodFromClassLoader));
}
use of org.junit.internal.runners.statements.Fail in project pact-jvm by DiUS.
the class InteractionRunner method interactionBlock.
protected Statement interactionBlock(final Interaction interaction) {
//1. prepare object
//2. get Target
//3. run Rule`s
//4. run Before`s
//5. run OnStateChange`s
//6. run test
//7. run After`s
final Object test;
try {
test = new ReflectiveCallable() {
@Override
protected Object runReflectiveCall() throws Throwable {
return createTest();
}
}.run();
} catch (Throwable e) {
return new Fail(e);
}
final Target target = testClass.getAnnotatedFieldValues(test, TestTarget.class, Target.class).get(0);
if (target instanceof TestClassAwareTarget) {
((TestClassAwareTarget) target).setTestClass(testClass, test);
}
Statement statement = new Statement() {
@Override
public void evaluate() throws Throwable {
target.testInteraction(pact.getConsumer().getName(), interaction);
}
};
statement = withStateChanges(interaction, test, statement);
statement = withBefores(interaction, test, statement);
statement = withRules(interaction, test, statement);
statement = withAfters(interaction, test, statement);
return statement;
}
use of org.junit.internal.runners.statements.Fail in project tomee by apache.
the class MetaRunner method methodBlock.
@Override
protected Statement methodBlock(final FrameworkMethod method) {
final Object test;
try {
test = new ReflectiveCallable() {
@Override
protected Object runReflectiveCall() throws Throwable {
return createTest();
}
}.run();
} catch (final Throwable e) {
return new Fail(e);
}
Statement statement = new MetaTest.$(method, test);
statement = withBefores(method, test, statement);
statement = withAfters(method, test, statement);
return statement;
}
use of org.junit.internal.runners.statements.Fail in project junit4 by junit-team.
the class BlockJUnit4ClassRunner method runChild.
//
// Implementation of ParentRunner
//
@Override
protected void runChild(final FrameworkMethod method, RunNotifier notifier) {
Description description = describeChild(method);
if (isIgnored(method)) {
notifier.fireTestIgnored(description);
} else {
Statement statement;
try {
statement = methodBlock(method);
} catch (Throwable ex) {
statement = new Fail(ex);
}
runLeaf(statement, description, notifier);
}
}
use of org.junit.internal.runners.statements.Fail in project pact-jvm by DiUS.
the class InteractionRunner method withStateChanges.
protected Statement withStateChanges(final Interaction interaction, final Object target, final Statement statement) {
if (StringUtils.isNotEmpty(interaction.getProviderState())) {
final String state = interaction.getProviderState();
final List<FrameworkMethod> onStateChange = new ArrayList<FrameworkMethod>();
for (FrameworkMethod ann : testClass.getAnnotatedMethods(State.class)) {
for (String annotationState : ann.getAnnotation(State.class).value()) {
if (annotationState.equalsIgnoreCase(state)) {
onStateChange.add(ann);
break;
}
}
}
if (onStateChange.isEmpty()) {
return new Fail(new MissingStateChangeMethod("MissingStateChangeMethod: Did not find a test class method annotated with @State(\"" + state + "\")"));
}
return new RunBefores(statement, onStateChange, target);
} else {
return statement;
}
}
Aggregations