kevinmost/junit-retry-rule: A simple @Rule for JUnit 4 to retry tests
In your test's class, add the RetryRule
as a test rule, by creating an instance of it as a public field, annotated with @Rule
.
@Rule public final RetryRule retry = new RetryRule();
Then, for any test that needs to implement retrying logic, annotate the method with @Retry
. Optional parameters on this annotation let you change defaults such as the number of retries, the timeout length, etc.
@Test @Retry(times = 5) // runs test up to 5 times, instead of the default 3 times public void myFlakyTest throws Exception { obj.doUnreliableThing(); }
Read full article from kevinmost/junit-retry-rule: A simple @Rule for JUnit 4 to retry tests
No comments:
Post a Comment