Annotation Interface RetryTest


JUnit annotation to mark a test method for retry on failure.

When a test fails, it will be retried up to the specified number of times. Optionally, a wait period can be specified between retry attempts.

This annotation automatically includes the RetryExtension, so no additional @ExtendWith annotation is required.

Usage examples:

 @RetryTest(3)
 void unstableTest() {
     // Test code that might fail intermittently
 }

 @RetryTest(value = 5, delay = 2)
 void testWithDelay() {
     // Test that waits 2 seconds between retry attempts
 }
Since:
1.0
Author:
Erik C. Thauvin
See Also:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    int
    The number of seconds to wait between retry attempts.
    Optional name for the test template.
    int
    The maximum number of retry attempts for a failing test.
  • Element Details

    • delay

      int delay
      The number of seconds to wait between retry attempts.

      If set to 0 (default), no wait occurs between retries. This can be useful for tests that interact with external systems that may need time to recover or stabilize.

      Returns:
      the wait time in seconds between retry attempts
      Default:
      0
    • name

      String name
      Optional name for the test template. If not specified, a default name will be generated.
      Returns:
      the display name for the retry test template
      Default:
      ""
    • value

      int value
      The maximum number of retry attempts for a failing test.

      The test will be executed at most value() times after the initial failure.

      Returns:
      the number of retry attempts. Must be greater than 0
      Default:
      3