Class RetryRule

java.lang.Object
org.apache.flink.testutils.junit.RetryRule
All Implemented Interfaces:
org.junit.rules.TestRule

public class RetryRule extends Object implements org.junit.rules.TestRule
A rule to retry failed tests for a fixed number of times.

Add the RetryRule to your test class and annotate the class and/or tests with either RetryOnFailure or RetryOnException. If both the class and test are annotated, then only the latter annotation is taken into account.

 @RetryOnFailure(times=1)
 public class YourTest {

     @Rule
     public RetryRule retryRule = new RetryRule();

     @Test
     public void yourTest() {
         // This will be retried 1 time (total runs 2) before failing the test.
         throw new Exception("Failing test");
     }

     @Test
     @RetryOnFailure(times=2)
     public void yourTest() {
         // This will be retried 2 time (total runs 3) before failing the test.
         throw new Exception("Failing test");
     }
 }
 
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final org.slf4j.Logger
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.junit.runners.model.Statement
    apply(org.junit.runners.model.Statement statement, org.junit.runner.Description description)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • LOG

      public static final org.slf4j.Logger LOG
  • Constructor Details

    • RetryRule

      public RetryRule()
  • Method Details

    • apply

      public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement statement, org.junit.runner.Description description)
      Specified by:
      apply in interface org.junit.rules.TestRule