Package org.junit.rules
Class Timeout
- java.lang.Object
-
- org.junit.rules.Timeout
-
- All Implemented Interfaces:
TestRule
public class Timeout extends java.lang.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 Timeout globalTimeout= new Timeout(20); @Test public void testInfiniteLoop1() { log+= "ran1"; for (;;) { } } @Test public void testInfiniteLoop2() { log+= "ran2"; for (;;) { } } }- Since:
- 4.7
-
-
Constructor Summary
Constructors Constructor Description Timeout(int millis)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Statementapply(Statement base, Description description)Modifies the method-runningStatementto implement this test-running rule.
-
-
-
Method Detail
-
apply
public Statement apply(Statement base, Description description)
Description copied from interface:TestRuleModifies the method-runningStatementto implement this test-running rule.- Specified by:
applyin interfaceTestRule- Parameters:
base- TheStatementto be modifieddescription- ADescriptionof the test implemented inbase- Returns:
- a new statement, which may be the same as
base, a wrapper aroundbase, or a completely new Statement.
-
-