use of org.junit.internal.runners.statements.RunAfters in project intellij-community by JetBrains.
the class GuiTestRunner method methodBlock.
@Override
protected Statement methodBlock(FrameworkMethod method) {
FrameworkMethod newMethod;
try {
if (Arrays.stream(getTestClass().getAnnotations()).anyMatch(annotation -> annotation instanceof ParentPlugin)) {
loadClassesWithNewPluginClassLoader();
} else {
loadClassesWithIdeClassLoader();
}
Method methodFromClassLoader = myTestClass.getJavaClass().getMethod(method.getName());
newMethod = new FrameworkMethod(methodFromClassLoader);
} catch (Exception e) {
return new Fail(e);
}
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(newMethod, test);
List<FrameworkMethod> beforeMethods = myTestClass.getAnnotatedMethods(Before.class);
if (!beforeMethods.isEmpty()) {
statement = new RunBefores(statement, beforeMethods, test);
}
List<FrameworkMethod> afterMethods = myTestClass.getAnnotatedMethods(After.class);
if (!afterMethods.isEmpty()) {
statement = new RunAfters(statement, afterMethods, test);
}
return statement;
}
use of org.junit.internal.runners.statements.RunAfters in project hazelcast by hazelcast.
the class AbstractHazelcastClassRunner method withAfters.
@Override
protected Statement withAfters(FrameworkMethod method, Object target, Statement statement) {
List<FrameworkMethod> afters = getTestClass().getAnnotatedMethods(After.class);
Statement nextStatement = statement;
List<TestRule> testRules = getTestRules(target);
if (!testRules.isEmpty()) {
for (TestRule rule : testRules) {
if (rule instanceof BounceMemberRule) {
nextStatement = ((BounceMemberRule) rule).stopBouncing(statement);
}
}
}
if (THREAD_DUMP_ON_FAILURE) {
return new ThreadDumpAwareRunAfters(method, nextStatement, afters, target);
}
if (afters.isEmpty()) {
return nextStatement;
} else {
return new RunAfters(nextStatement, afters, target);
}
}
Aggregations