public class RetryRule
extends java.lang.Object
implements org.junit.rules.TestRule, java.io.Serializable
@Rule
public final RetryRule retryRule = new RetryRule(3);
@Test
public void shouldBeRetriedUntilPasses() {
...
}
The above will result in 3 retries for every test in the test case.
RetryRule can be used locally for specific tests by annotating the test
method with @Rule and specifying a retryCount for that test:
@Rule
public final RetryRule retryRule = new RetryRule();
@Test
@Retry(3)
public void shouldBeRetriedUntilPasses() {
...
}
This version of RetryRule will retry a test that fails because of any kind
of Throwable.| Modifier and Type | Class and Description |
|---|---|
protected class |
RetryRule.AbstractRetryRule |
protected class |
RetryRule.GlobalRetryRule
Implementation of RetryRule for all test methods in a test case
|
protected class |
RetryRule.LocalRetryRule
Implementation of RetryRule for test methods annotated with Retry
|
| Modifier and Type | Method and Description |
|---|---|
org.junit.runners.model.Statement |
apply(org.junit.runners.model.Statement base,
org.junit.runner.Description description) |