org.junit.rules
Class Timeout
java.lang.Object
   org.junit.rules.Timeout
org.junit.rules.Timeout
- All Implemented Interfaces: 
- TestRule
- public class Timeout 
- extends Object- implements TestRule
The Timeout Rule applies the same timeout to all test methods in a class:
 
 
 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 (;;) {
                }
        }
 }
 
| Constructor Summary | 
| Timeout(int millis)
 | 
 
 
| Methods inherited from class java.lang.Object | 
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
 
Timeout
public Timeout(int millis)
- Parameters:
- millis- the millisecond timeout
apply
public Statement apply(Statement base,
                       Description description)
- Description copied from interface: TestRule
- Modifies the method-running Statementto implement this
 test-running rule.
 
- 
- Specified by:
- applyin interface- TestRule
 
- 
- Parameters:
- base- The- Statementto be modified
- description- A- Descriptionof the test implemented in- base
- Returns:
- a new statement, which may be the same as base,
 a wrapper aroundbase, or a completely new Statement.