Annotation Type CartesianTest


  • @TestTemplate
    @ExtendWith(CartesianTestExtension.class)
    @Target(METHOD)
    @Retention(RUNTIME)
    public @interface CartesianTest
    @CartesianTest is a JUnit Jupiter extension that marks a test to be executed with all possible input combinations.

    Methods annotated with this annotation should not be annotated with Test.

    This annotation is somewhat similar to @ParameterizedTest, as in it also takes arguments and can run the same test multiple times. With @CartesianTest you don't specify the test cases themselves, though. Instead you specify possible values for each test method parameter (for example with @CartesianTest.Values) by annotating the parameters themselves and the extension runs the method with each possible combination.

    You can specify a custom Display Name for the tests ran by @CartesianTest. By default it's [{index}] {arguments}.

    For more details and examples, see the documentation on @CartesianTest.

    Since:
    1.5.0
    • Field Summary

      Fields 
      Modifier and Type Fields Description
      static java.lang.String ARGUMENTS_PLACEHOLDER
      Placeholder for the complete, comma-separated arguments list of the current invocation of a @CartesianTest method: {arguments}
      static java.lang.String DISPLAY_NAME_PLACEHOLDER
      Placeholder for the display name of a @CartesianTest: {displayName}
      static java.lang.String INDEX_PLACEHOLDER
      Placeholder for the current invocation index of a @CartesianTest method (1-based): {index}
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      java.lang.String name
      The display name to be used for individual invocations of the parameterized test; never blank or consisting solely of whitespace.
    • Field Detail

      • DISPLAY_NAME_PLACEHOLDER

        static final java.lang.String DISPLAY_NAME_PLACEHOLDER
        Placeholder for the display name of a @CartesianTest: {displayName}
        Since:
        1.5
        See Also:
        name()
      • INDEX_PLACEHOLDER

        static final java.lang.String INDEX_PLACEHOLDER
        Placeholder for the current invocation index of a @CartesianTest method (1-based): {index}
        Since:
        1.5
        See Also:
        name()
      • ARGUMENTS_PLACEHOLDER

        static final java.lang.String ARGUMENTS_PLACEHOLDER
        Placeholder for the complete, comma-separated arguments list of the current invocation of a @CartesianTest method: {arguments}
        Since:
        1.5
        See Also:
        name()
    • Element Detail

      • name

        java.lang.String name
        The display name to be used for individual invocations of the parameterized test; never blank or consisting solely of whitespace.

        Defaults to [{index}] {arguments}.

        Supported placeholders:

        For the latter, you may use MessageFormat patterns to customize formatting.

        Since:
        1.5
        See Also:
        MessageFormat, ParameterizedTest.name()
        Default:
        "[{index}] {arguments}"