Annotation Type RepeatedTest



  • @Target({ANNOTATION_TYPE,METHOD})
    @Retention(RUNTIME)
    @Documented
    @API(status=STABLE,
         since="5.0")
    @TestTemplate
    public @interface RepeatedTest
    @RepeatedTest is used to signal that the annotated method is a test template method that should be repeated a specified number of times with a configurable display name.

    Each invocation of the repeated test behaves like the execution of a regular @Test method with full support for the same lifecycle callbacks and extensions. In addition, the current repetition and total number of repetitions can be accessed by having the RepetitionInfo injected.

    @RepeatedTest methods must not be private or static and must return void.

    @RepeatedTest methods may optionally declare parameters to be resolved by ParameterResolvers.

    @RepeatedTest may also be used as a meta-annotation in order to create a custom composed annotation that inherits the semantics of @RepeatedTest.

    Since:
    5.0
    See Also:
    DisplayName, RepetitionInfo, TestTemplate, TestInfo, Test
    • Field Summary

      Fields 
      Modifier and Type Fields Description
      static java.lang.String CURRENT_REPETITION_PLACEHOLDER
      Placeholder for the current repetition count of a @RepeatedTest method: {currentRepetition}
      static java.lang.String DISPLAY_NAME_PLACEHOLDER
      Placeholder for the display name of a @RepeatedTest method: {displayName}
      static java.lang.String LONG_DISPLAY_NAME
      Long display name pattern for a repeated test: "{displayName} :: repetition {currentRepetition} of {totalRepetitions}"
      static java.lang.String SHORT_DISPLAY_NAME
      Short display name pattern for a repeated test: "repetition {currentRepetition} of {totalRepetitions}"
      static java.lang.String TOTAL_REPETITIONS_PLACEHOLDER
      Placeholder for the total number of repetitions of a @RepeatedTest method: {totalRepetitions}
    • Required Element Summary

      Required Elements 
      Modifier and Type Required Element Description
      int value
      The number of repetitions.
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      java.lang.String name
      The display name for each repetition of the repeated test.
    • Field Detail

      • DISPLAY_NAME_PLACEHOLDER

        static final java.lang.String DISPLAY_NAME_PLACEHOLDER
        Placeholder for the display name of a @RepeatedTest method: {displayName}
      • CURRENT_REPETITION_PLACEHOLDER

        static final java.lang.String CURRENT_REPETITION_PLACEHOLDER
        Placeholder for the current repetition count of a @RepeatedTest method: {currentRepetition}
      • TOTAL_REPETITIONS_PLACEHOLDER

        static final java.lang.String TOTAL_REPETITIONS_PLACEHOLDER
        Placeholder for the total number of repetitions of a @RepeatedTest method: {totalRepetitions}
      • LONG_DISPLAY_NAME

        static final java.lang.String LONG_DISPLAY_NAME
        Long display name pattern for a repeated test: "{displayName} :: repetition {currentRepetition} of {totalRepetitions}"
        See Also:
        DISPLAY_NAME_PLACEHOLDER, SHORT_DISPLAY_NAME
    • Element Detail

      • value

        int value
        The number of repetitions.
        Returns:
        the number of repetitions; must be greater than zero