@Target(value={ANNOTATION_TYPE,METHOD}) @Retention(value=RUNTIME) @Documented @API(status=EXPERIMENTAL, since="5.0") @ArgumentsSource(value=org.junit.jupiter.params.provider.MethodArgumentsProvider.class) public @interface MethodSource
@MethodSource
is an ArgumentsSource
which provides access
to values returned from factory methods of the class in
which this annotation is declared or from static factory methods in external
classes referenced by fully qualified method name.
Each factory method must return a Stream
, Iterable
,
Iterator
, or array of arguments. The returned values will be provided
as arguments to the annotated @ParameterizedTest
method. If the parameterized test has a single parameter, each factory method
may return value instances, e.g. as Stream<String>
for a single
String
parameter, directly. If a parameterized test method declares
multiple parameters, factory methods must return instances of
Arguments
, e.g. as Stream<Arguments>
.
Factory methods within the test class must be must be static
unless
the PER_CLASS
test instance lifecycle mode is used; whereas, factory methods in external
classes must always be static
. In any case, factory methods must not
declare any parameters.
Arguments
,
ArgumentsSource
,
ParameterizedTest
,
TestInstance
public abstract String[] value
Factory methods in external classes must be referenced by fully
qualified method name — for example,
com.example.StringsProviders#blankStrings
.
If no factory method names are declared, a method within the test class that has the same name as the test method will be used as the factory method by default.
For further information, see the class-level JavaDoc.
Copyright © 2018. All rights reserved.