|
7 | 7 |
|
8 | 8 | import org.junit.experimental.theories.internal.SpecificDataPointsSupplier;
|
9 | 9 |
|
| 10 | +/** |
| 11 | + * <p> |
| 12 | + * Annotating a parameter of a {@link org.junit.experimental.theories.Theory |
| 13 | + * @Theory} method with <code>@FromDataPoints</code> will limit the |
| 14 | + * datapoints considered as potential values for that parameter to just the |
| 15 | + * {@link org.junit.experimental.theories.DataPoints DataPoints} with the |
| 16 | + * given name. For example: |
| 17 | + * </p> |
| 18 | + * |
| 19 | + * <pre> |
| 20 | + * @DataPoints |
| 21 | + * public static String[] unnamed = new String[] { ... }; |
| 22 | + * |
| 23 | + * @DataPoints("regexes") |
| 24 | + * public static String[] regexStrings = new String[] { ... }; |
| 25 | + * |
| 26 | + * @DataPoints({"forMatching", "alphanumeric"}) |
| 27 | + * public static String[] testStrings = new String[] { ... }; |
| 28 | + * |
| 29 | + * @Theory |
| 30 | + * public void stringTheory(String param) { |
| 31 | + * // This will be called with every value in 'regexStrings', |
| 32 | + * // 'testStrings' and 'unnamed'. |
| 33 | + * } |
| 34 | + * |
| 35 | + * @Theory |
| 36 | + * public void regexTheory(@FromDataPoints("regexes") String regex, |
| 37 | + * @FromDataPoints("forMatching") String value) { |
| 38 | + * // This will be called with only the values in 'regexStrings' as |
| 39 | + * // regex, only the values in 'testStrings' as value, and none |
| 40 | + * // of the values in 'unnamed'. |
| 41 | + * }</pre> |
| 42 | + * |
| 43 | + * @see org.junit.experimental.theories.Theory |
| 44 | + * @see org.junit.experimental.theories.DataPoint |
| 45 | + * @see org.junit.experimental.theories.DataPoints |
| 46 | + */ |
10 | 47 | @Retention(RetentionPolicy.RUNTIME)
|
11 | 48 | @Target(ElementType.PARAMETER)
|
12 | 49 | @ParametersSuppliedBy(SpecificDataPointsSupplier.class)
|
|
0 commit comments