Search in sources :

Example 11 with TestRule

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;
}
Also used : TestRule(org.junit.rules.TestRule) FrameworkMethod(org.junit.runners.model.FrameworkMethod)

Aggregations

TestRule (org.junit.rules.TestRule)11 Statement (org.junit.runners.model.Statement)7 FrameworkMethod (org.junit.runners.model.FrameworkMethod)4 BounceMemberRule (com.hazelcast.test.bounce.BounceMemberRule)2 EmptyStatement (com.hazelcast.util.EmptyStatement)2 ManagementFactory (java.lang.management.ManagementFactory)2 MonitorInfo (java.lang.management.MonitorInfo)2 ThreadInfo (java.lang.management.ThreadInfo)2 ThreadMXBean (java.lang.management.ThreadMXBean)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 ExecutionException (java.util.concurrent.ExecutionException)2 FutureTask (java.util.concurrent.FutureTask)2 TimeUnit (java.util.concurrent.TimeUnit)2 TimeoutException (java.util.concurrent.TimeoutException)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 Stream (java.util.stream.Stream)2 StringUtils.join (org.apache.commons.lang.StringUtils.join)2 Rule (org.junit.Rule)2 TestTimedOutException (org.junit.runners.model.TestTimedOutException)2 FieldInfo (org.spockframework.runtime.model.FieldInfo)2