junit-team/junit5 · error · TemplateInvocationValidationException
Configuration error: You must configure at least one set of…
Error message
Configuration error: You must configure at least one set of arguments for this @%s
What it means
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).
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
Example fix
// before — source may produce zero arguments
@ParameterizedTest
@MethodSource("dataProvider")
void test(int value) { }
static Stream<Arguments> dataProvider() {
return loadData().stream(); // empty if no data
}
// after — explicitly allow zero invocations, or guard the source
@ParameterizedTest
@MethodSource("dataProvider")
@EmptySource
void test(int value) { }
// OR ensure the source always has data:
static Stream<Arguments> dataProvider() {
var data = loadData();
org.junit.jupiter.api.Assumptions.assumeTrue(!data.isEmpty(), "No test data available");
return data.stream();
} Defensive patterns
Strategy: validation
Validate before calling
// Validate that the arguments source is non-empty before the parameterized test runs
import org.junit.jupiter.params.provider.Arguments;
import java.util.List;
static java.util.stream.Stream<Arguments> safeDataProvider() {
List<Arguments> data = loadData();
if (data.isEmpty()) {
org.junit.jupiter.api.Assumptions.assumeTrue(false,
"Skipping test: no arguments provided by data source");
}
return data.stream();
}
// Alternatively, annotate with @EmptySource if zero invocations is valid Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Configuration error: .
- Constructor injection is not supported for…
- configuration errors:%n
- The display name pattern defined for the parameterized test…
- When the display name pattern for a @
AI-assisted analysis of junit-team/junit5@f070c699a0 (2026-08-11).
Data as JSON: /api/errors/c55bb4cda4bd0c32.
Report an issue: GitHub.
Appendix: source
Thrown at junit-jupiter-params/src/main/java/org/junit/jupiter/params/ParameterizedInvocationContextProvider.java:59
.map(ArgumentsSource::value) //
.map(clazz -> ParameterizedTestSpiInstantiator.instantiate(ArgumentsProvider.class, clazz,
extensionContext)) //
.map(provider -> AnnotationConsumerInitializer.initialize(declarationContext.getAnnotatedElement(),
provider)) //
.flatMap(provider -> arguments(provider, parameters, extensionContext)) //
.map(arguments -> {
invocationCount.incrementAndGet();
return declarationContext.createInvocationContext(formatter, arguments, invocationCount.intValue());
}) //
.onClose(() -> validateInvokedAtLeastOnce(invocationCount.get(), declarationContext));
}
private static <T> void validateInvokedAtLeastOnce(long invocationCount,
ParameterizedDeclarationContext<T> declarationContext) {
if (invocationCount == 0 && !declarationContext.isAllowingZeroInvocations()) {
String message = "Configuration error: You must configure at least one set of arguments for this @%s".formatted(
declarationContext.getAnnotationName());
throw new TemplateInvocationValidationException(message);
}
}
private static List<ArgumentsSource> collectArgumentSources(ParameterizedDeclarationContext<?> declarationContext) {
List<ArgumentsSource> argumentsSources = findRepeatableAnnotations(declarationContext.getAnnotatedElement(),
ArgumentsSource.class);
Preconditions.notEmpty(argumentsSources,
() -> "Configuration error: You must configure at least one arguments source for this @%s".formatted(
declarationContext.getAnnotationName()));
return argumentsSources;
}
protected static Stream<? extends Arguments> arguments(ArgumentsProvider provider, ParameterDeclarations parameters,
ExtensionContext context) {
try {
return provider.provideArguments(parameters, context);View on GitHub (pinned to f070c699a0)