Annotation Type MethodSource



  • @Target({ANNOTATION_TYPE,METHOD})
    @Retention(RUNTIME)
    @Documented
    @API(status=EXPERIMENTAL,
         since="5.0")
    @ArgumentsSource(org.junit.jupiter.params.provider.MethodArgumentsProvider.class)
    public @interface MethodSource
    @MethodSource is an ArgumentsSource which provides access to values returned by factory methods of the class in which this annotation is declared.

    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>.

    By default, such factory methods must be static unless the PER_CLASS test instance lifecycle mode is used for the test class. Either way, factory methods must not declare any parameters.

    Since:
    5.0
    See Also:
    Arguments, ArgumentsSource, ParameterizedTest, TestInstance
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      java.lang.String[] value
      The names of the test class methods to use as sources for arguments; leave empty if the source method has the same name as the test method.
    • Element Detail

      • value

        java.lang.String[] value
        The names of the test class methods to use as sources for arguments; leave empty if the source method has the same name as the test method.
        Default:
        {""}