Annotation Type EnumSource
-
@Target({ANNOTATION_TYPE,METHOD,TYPE}) @Retention(RUNTIME) @Documented @Inherited @Repeatable(EnumSources.class) @API(status=STABLE, since="5.7") @ArgumentsSource(EnumArgumentsProvider.class) public @interface EnumSource@EnumSourceis a repeatableArgumentsSourcefor constants of anEnum.The enum constants will be provided as arguments to the annotated
@ParameterizedClassor@ParameterizedTest.The enum type can be specified explicitly using the
value()attribute. Otherwise, the declared type of the first parameter of the@ParameterizedClassor@ParameterizedTestis used.The set of enum constants can be restricted via the
names(),from(),to()andmode()attributes.Inheritance
This annotation is inherited to subclasses.
- Since:
- 5.0
- See Also:
ArgumentsSource,ParameterizedClass,ParameterizedTest
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description java.lang.StringfromThe starting enum constant of the range to be included.EnumSource.ModemodeThe enum constant selection mode.java.lang.String[]namesThe names of enum constants to provide, or regular expressions to select the names of enum constants to provide.java.lang.StringtoThe ending enum constant of the range to be included.java.lang.Class<? extends java.lang.Enum<?>>valueThe enum type that serves as the source of the enum constants.
-
-
-
Element Detail
-
value
java.lang.Class<? extends java.lang.Enum<?>> value
The enum type that serves as the source of the enum constants.If this attribute is not set explicitly, the declared type of the first parameter of the
@ParameterizedTestmethod is used.- Default:
- org.junit.jupiter.params.provider.NullEnum.class
-
-
-
names
java.lang.String[] names
The names of enum constants to provide, or regular expressions to select the names of enum constants to provide.If no names or regular expressions are specified, and neither
from()norto()are specified, all enum constants declared in the specified enum type will be provided.If
from()orto()are specified, the elements in names must fall within the range defined byfrom()andto().The
mode()determines how the names are interpreted.- Default:
- {}
-
-
-
mode
EnumSource.Mode mode
The enum constant selection mode.The mode only applies to the
names()attribute and does not change the behavior offrom()andto(), which always define a range based on the natural order of the enum constants.Defaults to
INCLUDE.- See Also:
EnumSource.Mode.INCLUDE,EnumSource.Mode.EXCLUDE,EnumSource.Mode.MATCH_ALL,EnumSource.Mode.MATCH_ANY,EnumSource.Mode.MATCH_NONE,names(),from(),to()
- Default:
- org.junit.jupiter.params.provider.EnumSource.Mode.INCLUDE
-
-