Skip to content

Commit 9b81f96

Browse files
committed
Added JavaDoc to DataPoints and FromDataPoints
1 parent 3375d1c commit 9b81f96

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

src/main/java/org/junit/experimental/theories/DataPoints.java

+37
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,43 @@
33
import java.lang.annotation.Retention;
44
import java.lang.annotation.RetentionPolicy;
55

6+
/**
7+
* <p>
8+
* Annotating an array-typed field or method with &#064;DataPoints will cause the
9+
* values in the array (or returned array) to be used as potential parameters
10+
* for theories in that class, when run with the
11+
* {@link org.junit.experimental.theories.Theories Theories} runner.
12+
* </p>
13+
* <p>
14+
* DataPoints will only be considered as potential values for parameters for
15+
* which their types are assignable. When multiple sets of DataPoints exist with
16+
* overlapping types more control can be obtained by naming the DataPoints using
17+
* the value of this annotation, e.g. with
18+
* <code>&#064;DataPoints({"dataset1", "dataset2"})</code>, and then specifying
19+
* which named set to consider as potential values for each parameter using the
20+
* {@link org.junit.experimental.theories.FromDataPoints &#064;FromDataPoints}
21+
* annotation.
22+
* </p>
23+
*
24+
* <pre>
25+
* &#064;DataPoints
26+
* public static String[] dataPoints = new String[] { ... };
27+
*
28+
* &#064;DataPoints
29+
* public static String[] generatedDataPoints() {
30+
* return new String[] { ... };
31+
* }
32+
*
33+
* &#064;Theory
34+
* public void theoryMethod(String param) {
35+
* ...
36+
* }</pre>
37+
*
38+
* @see org.junit.experimental.theories.Theories
39+
* @see org.junit.experimental.theories.Theory
40+
* @see org.junit.experimental.theories.DataPoint
41+
* @see org.junit.experimental.theories.FromDataPoints
42+
*/
643
@Retention(RetentionPolicy.RUNTIME)
744
public @interface DataPoints {
845
String[] value() default {};

src/main/java/org/junit/experimental/theories/FromDataPoints.java

+37
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,43 @@
77

88
import org.junit.experimental.theories.internal.SpecificDataPointsSupplier;
99

10+
/**
11+
* <p>
12+
* Annotating a parameter of a {@link org.junit.experimental.theories.Theory
13+
* &#064Theory} method with <code>&#064;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+
* &#064;DataPoints
21+
* public static String[] unnamed = new String[] { ... };
22+
*
23+
* &#064;DataPoints("regexes")
24+
* public static String[] regexStrings = new String[] { ... };
25+
*
26+
* &#064;DataPoints({"forMatching", "alphanumeric"})
27+
* public static String[] testStrings = new String[] { ... };
28+
*
29+
* &#064;Theory
30+
* public void stringTheory(String param) {
31+
* // This will be called with every value in 'regexStrings',
32+
* // 'testStrings' and 'unnamed'.
33+
* }
34+
*
35+
* &#064;Theory
36+
* public void regexTheory(&#064;FromDataPoints("regexes") String regex,
37+
* &#064;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+
*/
1047
@Retention(RetentionPolicy.RUNTIME)
1148
@Target(ElementType.PARAMETER)
1249
@ParametersSuppliedBy(SpecificDataPointsSupplier.class)

0 commit comments

Comments
 (0)