Annotation Interface DimensionMethodSource


@Retention(RUNTIME) @Target({PARAMETER,FIELD}) @Repeatable(List.class) public @interface DimensionMethodSource
Reference to a method providing a Stream, Collection or array of constraint annotations for a TestTemplate. The method will be invoked by the KafkaClusterExtension to provide a list of constraints over which the test will parameterized. The annotation should be used on a KafkaCluster-typed parameter of a TestTemplate-annotated method. The referenced method much be static and package- or publicly-accessible.

 @ExtendWith(KafkaClusterExtension.class)
 public class TemplateTest {
     @TestTemplate
     public void multipleClusterSizes(
             @DimensionMethodSource("clusterSizes")
             KafkaCluster cluster) throws Exception {
         // ... your test code
     }

     static Stream<BrokerCluster> clusterSizes() {
         return Stream.of(
             mkAnnotation(BrokerCluster.class, 1),
             mkAnnotation(BrokerCluster.class, 3));
     }
 }
 *

If multiple such annotation are present there will be a test for each element of the Cartesian product over each of the dimensions. If you want to execute a subset of the Cartesian product you might find @ConstraintsMethodSource more convenient.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static @interface 
    The interface List.
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The name of the static, package- or public-accessible method.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    The class where defining the static method, or Void.class (default), if the method is defined with the class defining the annotation test.
  • Element Details

    • value

      String value
      The name of the static, package- or public-accessible method.
      Returns:
      the string
    • clazz

      Class<?> clazz
      The class where defining the static method, or Void.class (default), if the method is defined with the class defining the annotation test.
      Returns:
      the class
      Default:
      java.lang.Void.class