forked from junit-team/junit4
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request junit-team#621 from pimterry/named-datapoints-#65
Added named datapoint(s) support to theories, fixing junit-team#65.
- Loading branch information
Showing
19 changed files
with
742 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
src/main/java/org/junit/experimental/theories/FromDataPoints.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package org.junit.experimental.theories; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
import org.junit.experimental.theories.internal.SpecificDataPointsSupplier; | ||
|
||
/** | ||
* <p> | ||
* Annotating a parameter of a {@link org.junit.experimental.theories.Theory | ||
* @Theory} method with <code>@FromDataPoints</code> will limit the | ||
* datapoints considered as potential values for that parameter to just the | ||
* {@link org.junit.experimental.theories.DataPoints DataPoints} with the given | ||
* name. DataPoint names can be given as the value parameter of the | ||
* @DataPoints annotation. | ||
* </p> | ||
* <p> | ||
* DataPoints without names will not be considered as values for any parameters | ||
* annotated with @FromDataPoints. | ||
* </p> | ||
* | ||
* <pre> | ||
* @DataPoints | ||
* public static String[] unnamed = new String[] { ... }; | ||
* | ||
* @DataPoints("regexes") | ||
* public static String[] regexStrings = new String[] { ... }; | ||
* | ||
* @DataPoints({"forMatching", "alphanumeric"}) | ||
* public static String[] testStrings = new String[] { ... }; | ||
* | ||
* @Theory | ||
* public void stringTheory(String param) { | ||
* // This will be called with every value in 'regexStrings', | ||
* // 'testStrings' and 'unnamed'. | ||
* } | ||
* | ||
* @Theory | ||
* public void regexTheory(@FromDataPoints("regexes") String regex, | ||
* @FromDataPoints("forMatching") String value) { | ||
* // This will be called with only the values in 'regexStrings' as | ||
* // regex, only the values in 'testStrings' as value, and none | ||
* // of the values in 'unnamed'. | ||
* } | ||
* </pre> | ||
* | ||
* @see org.junit.experimental.theories.Theory | ||
* @see org.junit.experimental.theories.DataPoint | ||
* @see org.junit.experimental.theories.DataPoints | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.PARAMETER) | ||
@ParametersSuppliedBy(SpecificDataPointsSupplier.class) | ||
public @interface FromDataPoints { | ||
String value(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.