junit-team/junit5 · error · ExtensionConfigurationException
When the display name pattern for a @%s contains %s, the arg
Error message
When the display name pattern for a @%s contains %s, the arguments must be supplied as an ArgumentSet.
What it means
Thrown by ArgumentSetNameFormatter.append() when the display name pattern contains {argumentSetName} but the current invocation's arguments were not created via Arguments.argumentSet(name, ...). The {argumentSetName} placeholder requires a named argument set; regular sources like @ValueSource, @CsvSource, or @MethodSource do not assign names to argument sets.
Source
Thrown at junit-jupiter-params/src/main/java/org/junit/jupiter/params/ParameterizedInvocationNameFormatter.java:231
@FunctionalInterface
private interface PartialFormatter {
PartialFormatter INDEX = (context, result) -> result.append(context.invocationIndex);
void append(ArgumentsContext context, StringBuffer result);
}
private record ArgumentSetNameFormatter(String annotationName) implements PartialFormatter {
@Override
public void append(ArgumentsContext context, StringBuffer result) {
if (context.argumentSetName != null) {
result.append(context.argumentSetName);
return;
}
throw new ExtensionConfigurationException(
"When the display name pattern for a @%s contains %s, the arguments must be supplied as an ArgumentSet.".formatted(
this.annotationName, ARGUMENT_SET_NAME_PLACEHOLDER));
}
}
private static class MessageFormatPartialFormatter implements PartialFormatter {
@SuppressWarnings("UnnecessaryUnicodeEscape")
private static final char ELLIPSIS = '\u2026';
private final MessageFormat messageFormat;
private final int argumentMaxLength;
private final boolean generateNameValuePairs;
private final @Nullable ResolverFacade resolverFacade;
MessageFormatPartialFormatter(String pattern, int argumentMaxLength) {
this(pattern, argumentMaxLength, false, null);
}View on GitHub (pinned to 956246301e)
Solutions
- Use {argumentSetNameOrArgumentsWithNames} instead of {argumentSetName} — it gracefully falls back to showing argument names when no set name exists
- If {argumentSetName} is required, change the arguments source to produce Arguments.argumentSet("myName", val1, val2) instead of Arguments.of(val1, val2)
- Use a simpler pattern like {index} or {arguments} if named sets are not needed
Example fix
// before
@ParameterizedTest(name = "{argumentSetName}")
@MethodSource("provider")
void test(int x) { }
static Stream<Arguments> provider() {
return Stream.of(Arguments.of(1)); // no name
}
// after (use argumentSet)
@ParameterizedTest(name = "{argumentSetName}")
@MethodSource("provider")
void test(int x) { }
static Stream<Arguments> provider() {
return Stream.of(Arguments.argumentSet("positive", 1));
} Defensive patterns
Strategy: validation
Validate before calling
// Use the safe alternative placeholder that falls back gracefully:
@ParameterizedTest(name = ParameterizedInvocationConstants.ARGUMENT_SET_NAME_OR_ARGUMENTS_WITH_NAMES_PLACEHOLDER)
// Or, if {argumentSetName} is used, ensure Arguments.argumentSet() is called:
static Stream<Arguments> provider() {
return Stream.of(Arguments.argumentSet("positive", 1, 2));
} Prevention
- Prefer {argumentSetNameOrArgumentsWithNames} over {argumentSetName} — it falls back to {argumentsWithNames} when no set name exists
- Only use {argumentSetName} when all argument sets are created via Arguments.argumentSet(name, ...)
- Do not mix Arguments.of(...) and Arguments.argumentSet(...) in the same source if using {argumentSetName}
When it happens
Trigger: Using name = "{argumentSetName}" (or explicitly referencing ARGUMENT_SET_NAME_PLACEHOLDER) on a @ParameterizedTest or @ParameterizedClass where arguments come from a source that does not use Arguments.argumentSet() — e.g., @ValueSource, @CsvSource, or a @MethodSource returning Arguments.of(...) instead of Arguments.argumentSet(...).
Common situations: Copying a display name pattern that was designed for named argument sets to a test that uses plain argument sources. Upgrading and adopting {argumentSetName} without switching the arguments source to use Arguments.argumentSet(). Note: {argumentSetNameOrArgumentsWithNames} is a safe alternative that falls back to {argumentsWithNames} when no name is set.
Related errors
- The display name pattern defined for the parameterized test
- Configuration error: You must configure at least one set of
- Failed to format display name for parameterized test. See ne
- Unsupported argument count validation mode: <mode>
- Constructor injection is not supported for @ParameterizedCla
AI-assisted analysis of junit-team/junit5@956246301e (2026-08-04).
Data as JSON: /data/errors/0f90e2c061d579e9.json.
Report an issue: GitHub.