diff options
Diffstat (limited to 'src/main/java/org/junit/experimental/theories/ParametersSuppliedBy.java')
-rw-r--r-- | src/main/java/org/junit/experimental/theories/ParametersSuppliedBy.java | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/src/main/java/org/junit/experimental/theories/ParametersSuppliedBy.java b/src/main/java/org/junit/experimental/theories/ParametersSuppliedBy.java index 8f090ef..15b5d95 100644 --- a/src/main/java/org/junit/experimental/theories/ParametersSuppliedBy.java +++ b/src/main/java/org/junit/experimental/theories/ParametersSuppliedBy.java @@ -1,12 +1,48 @@ package org.junit.experimental.theories; +import static java.lang.annotation.ElementType.ANNOTATION_TYPE; +import static java.lang.annotation.ElementType.PARAMETER; + import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; - +/** + * Annotating a {@link org.junit.experimental.theories.Theory Theory} method + * parameter with @ParametersSuppliedBy causes it to be supplied with + * values from the named + * {@link org.junit.experimental.theories.ParameterSupplier ParameterSupplier} + * when run as a theory by the {@link org.junit.experimental.theories.Theories + * Theories} runner. + * + * In addition, annotations themselves can be annotated with + * @ParametersSuppliedBy, and then used similarly. ParameterSuppliedBy + * annotations on parameters are detected by searching up this heirarchy such + * that these act as syntactic sugar, making: + * + * <pre> + * @ParametersSuppliedBy(Supplier.class) + * public @interface SpecialParameter { } + * + * @Theory + * public void theoryMethod(@SpecialParameter String param) { + * ... + * } + * </pre> + * + * equivalent to: + * + * <pre> + * @Theory + * public void theoryMethod(@ParametersSuppliedBy(Supplier.class) String param) { + * ... + * } + * </pre> + */ @Retention(RetentionPolicy.RUNTIME) +@Target({ ANNOTATION_TYPE, PARAMETER }) public @interface ParametersSuppliedBy { - Class<? extends ParameterSupplier> value(); + Class<? extends ParameterSupplier> value(); } |