use of org.junit.rules.TestRule in project randomizedtesting by randomizedtesting.
the class RandomizedRunner method wrapMethodRules.
/**
* Wrap the given statement in any declared MethodRules (old style rules).
*/
@SuppressWarnings("deprecation")
private Statement wrapMethodRules(Statement s, TestCandidate c, Object instance) {
FrameworkMethod fm = new FrameworkMethod(c.method);
// Old-style MethodRules first.
List<org.junit.rules.MethodRule> methodRules = getAnnotatedFieldValues(instance, Rule.class, org.junit.rules.MethodRule.class);
for (org.junit.rules.MethodRule rule : methodRules) {
s = rule.apply(s, fm, instance);
}
// New-style TestRule next.
List<TestRule> testRules = getAnnotatedFieldValues(instance, Rule.class, TestRule.class);
for (TestRule rule : testRules) {
s = rule.apply(s, c.description);
}
return s;
}
Aggregations