Class Timeout

  extended by org.junit.rules.Timeout
All Implemented Interfaces:

public class Timeout
extends Object
implements MethodRule

The Timeout Rule applies the same timeout to all test methods in a class:

 public static class HasGlobalTimeout {
        public static String log;
        public MethodRule globalTimeout= new Timeout(20);
        public void testInfiniteLoop1() {
                log+= "ran1";
                for (;;) {
        public void testInfiniteLoop2() {
                log+= "ran2";
                for (;;) {

Constructor Summary
Timeout(int millis)
Method Summary
 Statement apply(Statement base, FrameworkMethod method, Object target)
          Modifies the method-running Statement to implement an additional test-running rule.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public Timeout(int millis)
millis - the millisecond timeout
Method Detail


public Statement apply(Statement base,
                       FrameworkMethod method,
                       Object target)
Description copied from interface: MethodRule
Modifies the method-running Statement to implement an additional test-running rule.

Specified by:
apply in interface MethodRule
base - The Statement to be modified
method - The method to be run
target - The object on with the method will be run.
a new statement, which may be the same as base, a wrapper around base, or a completely new Statement.

API Documentation hosted by (