org.junit.contrib.theories.FromDataPoints Maven / Gradle / Ivy
package org.junit.contrib.theories;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import org.junit.contrib.theories.internal.SpecificDataPointsSupplier;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
/**
* Marking a parameter of a {@link Theory} method with this annotation will limit the data points considered
* as potential values for that parameter to only the {@link DataPoints} with the given name.
*
* Data points without names will not be considered as values for any parameters annotated with
* @FromDataPoints.
*
*
* @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'.
* }
*
*
* @see DataPoint
* @see DataPoints
* @see Theories
* @see Theory
*/
@Retention(RUNTIME)
@Target(PARAMETER)
@ParametersSuppliedBy(SpecificDataPointsSupplier.class)
public @interface FromDataPoints {
String value();
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy