Class AnnotationBasedInjectingExtension<A extends Annotation>

  • Type Parameters:
    A - The type of annotation to use for fields and/or parameters.
    All Implemented Interfaces:
    BeforeAllCallback, BeforeEachCallback, Extension, ParameterResolver

    public abstract class AnnotationBasedInjectingExtension<A extends Annotation>
    extends InjectingExtension
    An abstract base class for JUnit extensions that can inject values in fields and/or parameters, based on a specific annotation.

    A compatible annotation should look like this, where MyExtension extends AnnotationBasedInjectingExtension<MyAnnotation>:

    
     @ExtendWith(MyExtension.class)
     @Target({ ElementType.FIELD, ElementType.PARAMETER })
     @Retention(RetentionPolicy.RUNTIME)
     public @interface MyAnnotation {
         // add fields as needed
     }
     
    Author:
    Rob Spoor
    Since:
    2.0