@Retention(value=RUNTIME) @Target(value=METHOD) public @interface RetryOnException
RetryRule.
Add the RetryRule to your test and annotate tests
with RetryOnException.
public class YourTest {
@Rule
public RetryRule retryRule = new RetryRule();
@Test
@RetryOnException(times=1, exception=IOException.class)
public void yourTest() throws Exception {
// This will be retried 1 time (total runs 2) before failing the test.
throw new IOException("Failing test");
}
@Test
@RetryOnException(times=1, exception=IOException.class)
public void yourTest() throws Exception {
// This will not be retried, because it throws the wrong exception
throw new IllegalStateException("Failing test");
}
}
Copyright © 2014–2021 The Apache Software Foundation. All rights reserved.