Package org.robolectric.junit.rules
Class TimeoutRule
java.lang.Object
org.robolectric.junit.rules.TimeoutRule
- All Implemented Interfaces:
- org.junit.rules.TestRule
Robolectric's replacement for JUnit's 
Timeout.
 Timeout spawns a new thread, which is not compatible with
 Robolectric's Scheduler. Instead this Rule uses TimeLimitedStatement like @Test(timeout=)
 does.
 
Example usage:
 @Rule public final TimeoutRule timeoutRule = TimeoutRule.seconds(40);
 @Test
  public void testWhichShouldFinishIn40Seconds() {
    // ...
  }
 - 
Constructor SummaryConstructorsConstructorDescriptionTimeoutRule(long timeout, TimeUnit timeUnit) Create aTimeoutRuleinstance with the timeout specified at the timeUnit of granularity of the providedTimeUnit.
- 
Method SummaryModifier and TypeMethodDescriptionorg.junit.runners.model.Statementapply(org.junit.runners.model.Statement base, org.junit.runner.Description description) static TimeoutRulemillis(long millis) Creates aTimeoutRulethat will timeout a test after the given duration, in milliseconds.static TimeoutRuleseconds(long seconds) Creates aTimeoutRulethat will timeout a test after the given duration, in seconds.
- 
Constructor Details- 
TimeoutRuleCreate aTimeoutRuleinstance with the timeout specified at the timeUnit of granularity of the providedTimeUnit.- Parameters:
- timeout- the maximum time to allow the test to run before it should timeout
- timeUnit- the time unit for the- timeout
 
 
- 
- 
Method Details- 
applypublic org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description) - Specified by:
- applyin interface- org.junit.rules.TestRule
 
- 
millisCreates aTimeoutRulethat will timeout a test after the given duration, in milliseconds.
- 
secondsCreates aTimeoutRulethat will timeout a test after the given duration, in seconds.
 
-