{"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/956246301e03d757539f7b76dd5a91f298637563/junit-jupiter-params/src/main/java/org/junit/jupiter/params/ParameterizedInvocationContextProvider.java#L41-L77","documentation":"Thrown by ParameterizedInvocationContextProvider.validateInvokedAtLeastOnce() as a TemplateInvocationValidationException when the stream of arguments from all @ArgumentsSource providers yields zero invocations and zero invocations are not explicitly allowed. This means every arguments source produced an empty stream.","triggerScenarios":"A @ParameterizedTest or @ParameterizedClass annotated with an arguments source that produces zero arguments: an empty @ValueSource, a @MethodSource method returning Stream.empty(), an empty @CsvSource (no rows), or a @ArgumentsSource provider whose provideArguments() returns an empty stream.","commonSituations":"A @MethodSource factory method that filters to empty for a particular data set, an empty @CsvSource annotation left over from refactoring, a dynamic arguments source that yields no rows in certain environments, or using @EmptySource expecting it to provide arguments but combining it incorrectly.","solutions":["Ensure at least one arguments source produces at least one row of arguments","If zero arguments is a valid scenario, annotate with @ParameterizedClass(allowZeroInvocations = true) or @ParameterizedTest(allowZeroInvocations = true) (if supported by your version)","Debug the @MethodSource method or ArgumentsProvider to confirm it returns a non-empty stream","Check that @CsvSource has at least one value row (not just the annotation with no strings)"],"exampleFix":"// before\n@ParameterizedTest\n@MethodSource(\"emptyProvider\")\nvoid test(int x) { }\nstatic Stream<Integer> emptyProvider() { return Stream.empty(); }\n\n// after\n@ParameterizedTest\n@MethodSource(\"provider\")\nvoid test(int x) { }\nstatic Stream<Integer> provider() { return Stream.of(1, 2, 3); }","handlingStrategy":"validation","validationCode":"// Validate that your arguments provider returns at least one set:\nstatic <T> void assertNonEmpty(Stream<? extends Arguments> stream, String name) {\n    if (stream.findAny().isEmpty()) {\n        throw new IllegalStateException(\n            \"Arguments source '\" + name + \"' produced zero argument sets\");\n    }\n}\n// Or use allowZeroInvocations if zero is valid:\n// @ParameterizedTest(allowZeroInvocations = true)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure @ValueSource, @CsvSource, @EnumSource, and @MethodSource provide at least one row","Add @ParameterizedTest(allowZeroInvocations = true) if an empty source is a valid scenario","Unit-test your ArgumentsProvider or @MethodSource factory to confirm it returns non-empty streams","Check for conditional filtering in @MethodSource that may eliminate all elements"],"tags":["parameterized-test","arguments-source","empty-stream","configuration","junit-jupiter-params"],"analyzedSha":"956246301e03d757539f7b76dd5a91f298637563","analyzedAt":"2026-08-04T19:25:17.049Z","schemaVersion":2}