use of org.junit.runners.model.Statement in project tomee by apache.
the class SingleApplicationComposerRunner method rules.
@Override
protected List<MethodRule> rules(final Object test) {
final List<MethodRule> rules = super.rules(test);
rules.add(new MethodRule() {
@Override
public Statement apply(final Statement base, final FrameworkMethod method, final Object target) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
start(getTestClass().getJavaClass());
composerInject(target);
base.evaluate();
}
};
}
});
return rules;
}
use of org.junit.runners.model.Statement in project tomee by apache.
the class ApplicationComposer method rules.
@Override
protected List<MethodRule> rules(final Object test) {
final List<MethodRule> rules = super.rules(test);
rules.add(new MethodRule() {
public Statement apply(final Statement base, final FrameworkMethod method, final Object target) {
return new DeployApplication(target, base, delegate);
}
});
return rules;
}
use of org.junit.runners.model.Statement in project tomee by apache.
the class ApplicationRule method apply.
@Override
public Statement apply(final Statement statement, final Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
final Thread thread = Thread.currentThread();
final ClassLoader old = thread.getContextClassLoader();
final ApplicationComposers composers = new ApplicationOnlyApplicationComposers(instance);
composers.deployApp(instance);
try {
statement.evaluate();
} finally {
composers.stopApplication();
thread.setContextClassLoader(old);
}
}
};
}
use of org.junit.runners.model.Statement 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.runners.model.Statement in project blueocean-plugin by jenkinsci.
the class ATHJUnitRunner method methodInvoker.
@Override
protected Statement methodInvoker(FrameworkMethod method, Object test) {
Statement next = super.methodInvoker(method, test);
return new Statement() {
@Override
public void evaluate() throws Throwable {
LoginPage loginPage = injector.getInstance(LoginPage.class);
Login methodLogin = method.getAnnotation(Login.class);
// first check test method, then walk up hierarchy at class level only
if (methodLogin != null) {
if (!methodLogin.disable()) {
loginPage.login();
}
} else {
Class<?> clazz = test.getClass();
while (clazz != null) {
Login classLogin = clazz.getAnnotation(Login.class);
if (classLogin != null) {
if (!classLogin.disable()) {
loginPage.login();
}
break;
}
clazz = clazz.getSuperclass();
}
}
try {
next.evaluate();
outputConsoleLogs();
} catch (Exception e) {
writeScreenShotCause(e, test, method);
outputConsoleLogs();
throw e;
}
WebDriver driver = injector.getInstance(WebDriver.class);
driver.close();
// driver.quit();
}
};
}
Aggregations