@Target(value={ANNOTATION_TYPE,METHOD}) @Retention(value=RUNTIME) @Documented @API(status=EXPERIMENTAL, since="5.0") @TestTemplate @ExtendWith(value=org.junit.jupiter.params.ParameterizedTestExtension.class) public @interface ParameterizedTest
@ParameterizedTest is used to signal that the annotated method is a
parameterized test method.
Such methods must not be private or static.
@ParameterizedTest methods must specify at least one
ArgumentsProvider
via @ArgumentsSource
or a corresponding composed annotation (e.g., @ValueSource,
@CsvSource, etc.). The provider is responsible for providing a
Stream of
Arguments that will be
used to invoke the parameterized test method.
A @ParameterizedTest method may declare additional parameters at
the end of the method's parameter list to be resolved by other
ParameterResolvers
(e.g., TestInfo, TestReporter, etc). Specifically, a
parameterized test method must declare formal parameters according to the
following rules.
ParameterResolver
implementations must be declared last.In this context, an indexed argument is an argument for a given
index in the Arguments provided by an ArgumentsProvider that
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 type
ArgumentsAccessor
or any parameter annotated with
@AggregateWith.
Method parameters may be annotated with
@ConvertWith
or a corresponding composed annotation to specify an explicit
ArgumentConverter.
Otherwise, JUnit Jupiter will attempt to perform an implicit
conversion to the target type automatically (see the User Guide for further
details).
@ParameterizedTest may also be used as a meta-annotation in order
to create a custom composed annotation that inherits the semantics
of @ParameterizedTest.
Arguments,
ArgumentsProvider,
ArgumentsSource,
CsvFileSource,
CsvSource,
EnumSource,
MethodSource,
ValueSource,
ArgumentsAccessor,
AggregateWith,
ArgumentConverter,
ConvertWith| Modifier and Type | Fields and Description |
|---|---|
static String |
ARGUMENTS_PLACEHOLDER
Placeholder for the complete, comma-separated arguments list of the
current invocation of a
@ParameterizedTest method:
{arguments} |
static String |
DEFAULT_DISPLAY_NAME
Default display name pattern for the current invocation of a
@ParameterizedTest method: "[{index}] {arguments}" |
static String |
DISPLAY_NAME_PLACEHOLDER
|
static String |
INDEX_PLACEHOLDER
Placeholder for the current invocation index of a
@ParameterizedTest
method (1-based): {index} |
@API(status=EXPERIMENTAL,
since="5.3")
public static final String DEFAULT_DISPLAY_NAME
@ParameterizedTest method: "[{index}] {arguments}"
Note that the default pattern does not include the
display name of the
@ParameterizedTest method.
name(),
DISPLAY_NAME_PLACEHOLDER,
INDEX_PLACEHOLDER,
ARGUMENTS_PLACEHOLDERpublic abstract String name
Defaults to DEFAULT_DISPLAY_NAME.
DISPLAY_NAME_PLACEHOLDERINDEX_PLACEHOLDERARGUMENTS_PLACEHOLDER{0}, {1}, etc.: an individual argument (0-based)For the latter, you may use MessageFormat patterns
to customize formatting.
MessageFormatCopyright © 2018. All rights reserved.