Annotation Type JsonClasspathSource


@Target({METHOD,PARAMETER}) @Retention(RUNTIME) @Documented @ArgumentsSource(org.junitpioneer.jupiter.json.JsonClasspathSourceArgumentsProvider.class) public @interface JsonClasspathSource
@JsonClasspathSource is an ArgumentsSource that loads JSON from a classpath resource, parses it, and passes it as arguments to a parametrized test.

This annotation can be used on a method parameter, to make it usable with CartesianTest. If used with ParameterizedTest, the annotation has to be on the method itself as any other ArgumentsSource.

Note that this extension requires a JSON parser to be available at run time, which may include adding it to the module graph with --add-modules. For details on that as well as how to use this extension, see the documentation on JSON tests

Since:
1.7.0
See Also:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    The name of the element from which the data should be extracted from.
    The JSON classpath resources to use as the sources of arguments; must not be empty.
  • Element Details

    • value

      String[] value
      The JSON classpath resources to use as the sources of arguments; must not be empty.
      Default:
      {}
    • data

      String data
      The name of the element from which the data should be extracted from. If not set the root element will be used.
      Default:
      ""