org.junit.rules.TestRule which enables to run the same JUnit test
repeatedly. Add this rule to the test class
public class MyTest {
@Rule
public RepeatRule repeatRule = new RepeatRule();
...
}
and annotate the test to be repeated with the
@Repeat(n=<repetitions>) annotation
@Test
@Repeat(n = 100)
public void test() {
...
}
then this test will be repeated 100 times. If any test execution fails test
repetition will be stopped.
| Modifier and Type | Class and Description |
|---|---|
| public static class | RepeatRule.
Exception thrown if repeated execution of a test annotated with
|
| private static class |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public Statement | apply(Statement
The statement, Description Statement to be modifiedA description)Description of the test implemented in baseImplements org. Modifies the method-running |
| LOG | back to summary |
|---|---|
| private static final Logger LOG | |
| RepeatRule | back to summary |
|---|---|
| public RepeatRule() | |
| apply | back to summary |
|---|---|
| public Statement apply(Statement statement, Description description) Implements org. Doc from org. Modifies the method-running
| |
@Repeat failed.
| Modifier and Type | Field and Description |
|---|---|
| private static final long |
| Access | Constructor and Description |
|---|---|
| public | |
| public | RepeatedTestException(String
the error message message, Throwable exception causing this exception cause)Constructor |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| RepeatedTestException | back to summary |
|---|---|
| public RepeatedTestException(String message) Constructor
| |
| RepeatedTestException | back to summary |
|---|---|
| public RepeatedTestException(String message, Throwable cause) Constructor | |
| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| private final int | |
| private final Statement |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public void | evaluate()
Implements abstract org. Run the action, throwing a |
| abortOnFailure | back to summary |
|---|---|
| private boolean abortOnFailure | |
| repetitions | back to summary |
|---|---|
| private final int repetitions | |
| statement | back to summary |
|---|---|
| private final Statement statement | |
| RepeatStatement | back to summary |
|---|---|
| private RepeatStatement(int repetitions, boolean abortOnFailure, Statement statement) | |
| evaluate | back to summary |
|---|---|
| public void evaluate() throws Throwable Implements abstract org. Doc from org. Run the action, throwing a
| |