{"record":{"id":"c55bb4cda4bd0c32","repo":"junit-team/junit5","slug":"configuration-error-you-must-configure-at-least-o","errorCode":null,"errorMessage":"Configuration error: You must configure at least one set of arguments for this @%s","messagePattern":"Configuration error: You must configure at least one set of arguments for this @(.+?)","errorType":"exception","errorClass":"TemplateInvocationValidationException","httpStatus":null,"severity":"error","filePath":"junit-jupiter-params/src/main/java/org/junit/jupiter/params/ParameterizedInvocationContextProvider.java","lineNumber":59,"sourceCode":"\t\t\t\t.map(ArgumentsSource::value) //\n\t\t\t\t.map(clazz -> ParameterizedTestSpiInstantiator.instantiate(ArgumentsProvider.class, clazz,\n\t\t\t\t\textensionContext)) //\n\t\t\t\t.map(provider -> AnnotationConsumerInitializer.initialize(declarationContext.getAnnotatedElement(),\n\t\t\t\t\tprovider)) //\n\t\t\t\t.flatMap(provider -> arguments(provider, parameters, extensionContext)) //\n\t\t\t\t.map(arguments -> {\n\t\t\t\t\tinvocationCount.incrementAndGet();\n\t\t\t\t\treturn declarationContext.createInvocationContext(formatter, arguments, invocationCount.intValue());\n\t\t\t\t}) //\n\t\t\t\t.onClose(() -> validateInvokedAtLeastOnce(invocationCount.get(), declarationContext));\n\t}\n\n\tprivate static <T> void validateInvokedAtLeastOnce(long invocationCount,\n\t\t\tParameterizedDeclarationContext<T> declarationContext) {\n\t\tif (invocationCount == 0 && !declarationContext.isAllowingZeroInvocations()) {\n\t\t\tString message = \"Configuration error: You must configure at least one set of arguments for this @%s\".formatted(\n\t\t\t\tdeclarationContext.getAnnotationName());\n\t\t\tthrow new TemplateInvocationValidationException(message);\n\t\t}\n\t}\n\n\tprivate static List<ArgumentsSource> collectArgumentSources(ParameterizedDeclarationContext<?> declarationContext) {\n\t\tList<ArgumentsSource> argumentsSources = findRepeatableAnnotations(declarationContext.getAnnotatedElement(),\n\t\t\tArgumentsSource.class);\n\n\t\tPreconditions.notEmpty(argumentsSources,\n\t\t\t() -> \"Configuration error: You must configure at least one arguments source for this @%s\".formatted(\n\t\t\t\tdeclarationContext.getAnnotationName()));\n\n\t\treturn argumentsSources;\n\t}\n\n\tprotected static Stream<? extends Arguments> arguments(ArgumentsProvider provider, ParameterDeclarations parameters,\n\t\t\tExtensionContext context) {\n\t\ttry {\n\t\t\treturn provider.provideArguments(parameters, context);","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/junit-team/junit5/blob/f070c699a08b5d8393df9afd147af5c5e90bb21b/junit-jupiter-params/src/main/java/org/junit/jupiter/params/ParameterizedInvocationContextProvider.java#L41-L77","documentation":"Thrown when a parameterized test or @ParameterizedClass annotation has an arguments source configured but that source produces zero arguments, and the annotation does not declare @AllowZeroInvocations (or equivalent). This is validated in the onClose callback of the arguments stream, meaning the provider was iterated but yielded no elements. The %s placeholder is filled with the annotation name (e.g., ParameterizedTest, ParameterizedClass).","triggerScenarios":"A @ParameterizedTest with @CsvSource referencing an empty file or a CSV string with only headers. A @MethodSource pointing to a method that returns an empty Stream. A @ValueSource with no values (which is typically caught earlier). A custom ArgumentsProvider that returns an empty stream under certain conditions.","commonSituations":"Data-driven tests where the data source is environment-dependent (e.g., a CSV file that exists in dev but not in CI). @MethodSource methods with conditional logic that filters out all rows. Empty @CsvFileSource resources. Tests parameterized by database state where the query returns no rows in a fresh environment.","solutions":["Verify the arguments source actually produces data — check the CSV file path, the method source return value, or the provider logic","If zero arguments is a valid scenario, annotate the test with @EmptySource to explicitly allow zero invocations","For @MethodSource, add a debug log or assertion to confirm the source method returns non-empty data in the failing environment","For file-based sources (@CsvFileSource), verify the file exists on the classpath and is not empty"],"exampleFix":"// before — source may produce zero arguments\n@ParameterizedTest\n@MethodSource(\"dataProvider\")\nvoid test(int value) { }\n\nstatic Stream<Arguments> dataProvider() {\n    return loadData().stream(); // empty if no data\n}\n\n// after — explicitly allow zero invocations, or guard the source\n@ParameterizedTest\n@MethodSource(\"dataProvider\")\n@EmptySource\nvoid test(int value) { }\n\n// OR ensure the source always has data:\nstatic Stream<Arguments> dataProvider() {\n    var data = loadData();\n    org.junit.jupiter.api.Assumptions.assumeTrue(!data.isEmpty(), \"No test data available\");\n    return data.stream();\n}","handlingStrategy":"validation","validationCode":"// Validate that the arguments source is non-empty before the parameterized test runs\nimport org.junit.jupiter.params.provider.Arguments;\nimport java.util.List;\n\nstatic java.util.stream.Stream<Arguments> safeDataProvider() {\n    List<Arguments> data = loadData();\n    if (data.isEmpty()) {\n        org.junit.jupiter.api.Assumptions.assumeTrue(false,\n            \"Skipping test: no arguments provided by data source\");\n    }\n    return data.stream();\n}\n\n// Alternatively, annotate with @EmptySource if zero invocations is valid","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use JUnit Assumptions.assumeTrue(!data.isEmpty()) in @MethodSource methods to skip gracefully when data is unavailable","For file-based sources (@CsvFileSource), verify the resource exists on the classpath in CI environments","Add @EmptySource to parameterized tests where zero arguments is a valid scenario"],"tags":["parameterized-test","arguments-source","configuration","junit-params"],"backgroundTag":null,"analyzedSha":"f070c699a08b5d8393df9afd147af5c5e90bb21b","analyzedAt":"2026-08-11T20:31:00.530Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}