Package dev.dokimos.junit
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 resourceclasspath:datasets/dataset.jsonl- classpath JSONL resourcefile:path/to/dataset.json- file pathpath/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
-
Element Details
-
value
String valueURI of the dataset to load. Supports: classpath:, file:, or plain file paths.- Default:
""
-
json
String jsonInline JSON dataset. Use this for small/quick tests only.- Default:
""
-
jsonl
String jsonlInline JSONL dataset. Each line is a JSON object. Use this for small/quick tests only.- Default:
""
-