Annotation Interface DatasetSource


@Target(METHOD) @Retention(RUNTIME) @ArgumentsSource(DatasetArgumentsProvider.class) public @interface DatasetSource
Provides Examples from a Dataset as arguments to a parameterized test.

Supports multiple source types:

  • classpath:datasets/dataset.json - classpath JSON resource
  • classpath:datasets/dataset.jsonl - classpath JSONL resource
  • file:path/to/dataset.json - file path
  • path/to/dataset.json - file path (default)
  • Inline JSON via json()
  • Inline JSONL via jsonl()

Example usage:


 @ParameterizedTest
 @DatasetSource("classpath:datasets/qa.json")
 void testQa(Example example) {
     String answer = aiService.generate(example.input());
     Assertions.assertEval(example.toTestCase(answer), evaluators);
 }
 
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Inline JSON dataset.
    Inline JSONL dataset.
    URI of the dataset to load.
  • Element Details

    • value

      String value
      URI of the dataset to load. Supports: classpath:, file:, or plain file paths.
      Default:
      ""
    • json

      String json
      Inline JSON dataset. Use this for small/quick tests only.
      Default:
      ""
    • jsonl

      String jsonl
      Inline JSONL dataset. Each line is a JSON object. Use this for small/quick tests only.
      Default:
      ""