Package dev.dokimos.junit
Annotation Interface DatasetSource
@Target(METHOD)
@Retention(RUNTIME)
@ArgumentsSource(DatasetArgumentsProvider.class)
@ExtendWith(DatasetRunExtension.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 ElementsModifier and TypeOptional ElementDescriptionRun metadata as typed key-value entries (for example{@MetadataEntry(key = "model", value = "gpt-4")}).Name of the run opened when aDatasetReporterfield is present.Inline JSON dataset.Inline JSONL dataset.String[]Run metadata as alternating key-value pairs (for example{"model", "gpt-4", "temperature", "0"}).URI of the dataset to load.
-
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:
""
-
experimentName
String experimentNameName of the run opened when aDatasetReporterfield is present. Defaults to the test method name when left empty.- Default:
""
-
metadata
String[] metadataRun metadata as alternating key-value pairs (for example{"model", "gpt-4", "temperature", "0"}). Forwarded to the reporter when aDatasetReporterfield is present. Defaults to no metadata.- Default:
{}
-
entries
MetadataEntry[] entriesRun metadata as typed key-value entries (for example{@MetadataEntry(key = "model", value = "gpt-4")}). Forwarded to the reporter when aDatasetReporterfield is present. When non-empty this takes precedence overmetadata(). Defaults to no metadata.- Default:
{}
-