Annotation Type ParameterizedTest
-
@Target({ANNOTATION_TYPE,METHOD}) @Retention(RUNTIME) @Documented @API(status=EXPERIMENTAL, since="5.0") @TestTemplate @ExtendWith(org.junit.jupiter.params.ParameterizedTestExtension.class) public @interface ParameterizedTest
@ParameterizedTestis used to signal that the annotated method is a parameterized test method.Such methods must not be
privateorstatic.Argument Providers and Sources
@ParameterizedTestmethods must specify at least oneArgumentsProvidervia@ArgumentsSourceor a corresponding composed annotation (e.g.,@ValueSource,@CsvSource, etc.). The provider is responsible for providing aStreamofArgumentsthat will be used to invoke the parameterized test method.Formal Parameter List
A
@ParameterizedTestmethod may declare additional parameters at the end of the method's parameter list to be resolved by otherParameterResolvers(e.g.,TestInfo,TestReporter, etc). Specifically, a parameterized test method must declare formal parameters according to the following rules.- Zero or more indexed arguments must be declared first.
- Zero or more aggregators must be declared next.
- Zero or more arguments supplied by other
ParameterResolverimplementations must be declared last.
In this context, an indexed argument is an argument for a given index in the
Argumentsprovided by anArgumentsProviderthat is passed as an argument to the parameterized method at the same index in the method's formal parameter list. An aggregator is any parameter of typeArgumentsAccessoror any parameter annotated with@AggregateWith.Argument Conversion
Method parameters may be annotated with
@ConvertWithor a corresponding composed annotation to specify an explicitArgumentConverter. Otherwise, JUnit Jupiter will attempt to perform an implicit conversion to the target type automatically (see the User Guide for further details).Composed Annotations
@ParameterizedTestmay also be used as a meta-annotation in order to create a custom composed annotation that inherits the semantics of@ParameterizedTest.- Since:
- 5.0
- See Also:
Arguments,ArgumentsProvider,ArgumentsSource,CsvFileSource,CsvSource,EnumSource,MethodSource,ValueSource,ArgumentsAccessor,AggregateWith,ArgumentConverter,ConvertWith
-
-
Element Detail
-
name
String name
The name pattern to be used for invocations of the parameterized test; never blank or consisting solely of whitespace.You may use the following placeholders:
{index}: the current invocation index (1-based){arguments}: the complete, comma-separated arguments list{0},{1}, etc.: an individual argument (0-based)
For the latter, you may use
MessageFormatpatterns to customize formatting of values.- See Also:
MessageFormat
- Default:
- "[{index}] {arguments}"
-
-