use of org.junit.rules.MethodRule in project spock by spockframework.
the class MethodRuleInterceptor method intercept.
@Override
public void intercept(final IMethodInvocation invocation) throws Throwable {
Statement statement = createBaseStatement(invocation);
FrameworkMethod method = createFrameworkMethod(invocation);
for (FieldInfo field : ruleFields) {
MethodRule rule = (MethodRule) getRuleInstance(field, invocation.getInstance());
statement = rule.apply(statement, method, invocation.getInstance());
}
statement.evaluate();
}
use of org.junit.rules.MethodRule in project querydsl by querydsl.
the class HibernateTestRunner method rules.
@Override
protected List<MethodRule> rules(Object test) {
assertTrue(String.format("In order to use the %s for %s, it should (directly or indirectly) implement %s", HibernateTestRunner.class.getSimpleName(), test.getClass(), HibernateTest.class), test instanceof HibernateTest);
List<MethodRule> rules = super.rules(test);
rules.add(new MethodRule() {
@Override
public Statement apply(final Statement base, FrameworkMethod method, final Object target) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
((HibernateTest) target).setSession(session);
base.evaluate();
}
};
}
});
return rules;
}
use of org.junit.rules.MethodRule in project querydsl by querydsl.
the class JPATestRunner method rules.
@Override
protected List<MethodRule> rules(Object test) {
Assert.assertTrue(String.format("In order to use the %s for %s, it should (directly or indirectly) implement %s", JPATestRunner.class.getSimpleName(), test.getClass(), JPATest.class), test instanceof JPATest);
List<MethodRule> rules = super.rules(test);
rules.add(new MethodRule() {
@Override
public Statement apply(final Statement base, FrameworkMethod method, final Object target) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
((JPATest) target).setEntityManager(entityManager);
base.evaluate();
}
};
}
});
return rules;
}
use of org.junit.rules.MethodRule in project tomee by apache.
the class TomEEEmbeddedSingleRunner 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 {
BASE.start(test);
BASE.composerInject(target);
base.evaluate();
}
};
}
});
return rules;
}
use of org.junit.rules.MethodRule 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 {
BASE.start(getTestClass().getJavaClass());
BASE.composerInject(target);
base.evaluate();
}
};
}
});
return rules;
}
Aggregations