public class Timeout extends Object implements MethodRule
public static class HasGlobalTimeout {
public static String log;
@Rule
public MethodRule globalTimeout= new Timeout(20);
@Test
public void testInfiniteLoop1() {
log+= "ran1";
for (;;) {
}
}
@Test
public void testInfiniteLoop2() {
log+= "ran2";
for (;;) {
}
}
}
public Statement apply(Statement base, FrameworkMethod method, Object target)
MethodRuleStatement to implement an additional
test-running rule.apply in interface MethodRulebase - The Statement to be modifiedmethod - The method to be runtarget - The object on with the method will be run.base,
a wrapper around base, or a completely new Statement.