Annotation Type DisableIfArgument


@Target(METHOD) @Retention(RUNTIME) @Repeatable(DisableIfArgument.DisableIfArguments.class) @ExtendWith(DisableIfArgumentExtension.class) public @interface DisableIfArgument
@DisableIfArgument is a JUnit Jupiter extension that selectively disables a ParameterizedTest execution if the specified argument (as defined by Object.toString()) satisfies the specified condition.

The extension uses Jupiter's InvocationInterceptor. It's important to note that since it's marked as

invalid reference
org.apiguardian.api.API.Status#EXPERIMENTAL
it might be removed without prior notice. Unlike Disabled annotations, this extension doesn't disable the whole test method. With DisableIfArgument, it is possible to selectively disable tests out of the plethora of dynamically registered parameterized tests.

The extension requires that exactly one of contains or matches is configured.

This annotation is for disabling a test based on a single argument which can be designated with an implicit index, an explicit index or by name (if parameter name information is present). For more information how the extension resolves the annotations, check the documentation on disabling parameterized tests.

Since:
1.5.0
See Also:
  • Element Details

    • name

      String name
      The name of the parameter the extension checks. If parameter naming information is not present at runtime, setting this will throw ParameterResolutionException.
      Default:
      ""
    • index

      int index
      The index of the parameter the extension checks, starting from 0. Negative values are ignored. Setting this to a number higher than the parameter count of the test method will result in ExtensionConfigurationException.
      Default:
      -1
    • contains

      String[] contains
      Disable test cases whose argument (converted to String with Object.toString()) contains any of the specified strings (according to String.contains(CharSequence)).
      Default:
      {}
    • matches

      String[] matches
      Disable test cases whose argument (converted to String with Object.toString()) matches any of the specified regular expressions (according to String.matches(String)).
      Default:
      {}