{"id":"0f90e2c061d579e9","repo":"junit-team/junit5","slug":"when-the-display-name-pattern-for-a-s-contains","errorCode":null,"errorMessage":"When the display name pattern for a @%s contains %s, the arguments must be supplied as an ArgumentSet.","messagePattern":"When the display name pattern for a @(.+?) contains (.+?), the arguments must be supplied as an ArgumentSet\\.","errorType":"exception","errorClass":"ExtensionConfigurationException","httpStatus":null,"severity":"error","filePath":"junit-jupiter-params/src/main/java/org/junit/jupiter/params/ParameterizedInvocationNameFormatter.java","lineNumber":231,"sourceCode":"\n\t@FunctionalInterface\n\tprivate interface PartialFormatter {\n\n\t\tPartialFormatter INDEX = (context, result) -> result.append(context.invocationIndex);\n\n\t\tvoid append(ArgumentsContext context, StringBuffer result);\n\n\t}\n\n\tprivate record ArgumentSetNameFormatter(String annotationName) implements PartialFormatter {\n\n\t\t@Override\n\t\tpublic void append(ArgumentsContext context, StringBuffer result) {\n\t\t\tif (context.argumentSetName != null) {\n\t\t\t\tresult.append(context.argumentSetName);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthrow new ExtensionConfigurationException(\n\t\t\t\t\"When the display name pattern for a @%s contains %s, the arguments must be supplied as an ArgumentSet.\".formatted(\n\t\t\t\t\tthis.annotationName, ARGUMENT_SET_NAME_PLACEHOLDER));\n\t\t}\n\t}\n\n\tprivate static class MessageFormatPartialFormatter implements PartialFormatter {\n\n\t\t@SuppressWarnings(\"UnnecessaryUnicodeEscape\")\n\t\tprivate static final char ELLIPSIS = '\\u2026';\n\n\t\tprivate final MessageFormat messageFormat;\n\t\tprivate final int argumentMaxLength;\n\t\tprivate final boolean generateNameValuePairs;\n\t\tprivate final @Nullable ResolverFacade resolverFacade;\n\n\t\tMessageFormatPartialFormatter(String pattern, int argumentMaxLength) {\n\t\t\tthis(pattern, argumentMaxLength, false, null);\n\t\t}","sourceCodeStart":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/junit-team/junit5/blob/956246301e03d757539f7b76dd5a91f298637563/junit-jupiter-params/src/main/java/org/junit/jupiter/params/ParameterizedInvocationNameFormatter.java#L213-L249","documentation":"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.","triggerScenarios":"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(...).","commonSituations":"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.","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"],"exampleFix":"// before\n@ParameterizedTest(name = \"{argumentSetName}\")\n@MethodSource(\"provider\")\nvoid test(int x) { }\nstatic Stream<Arguments> provider() {\n    return Stream.of(Arguments.of(1)); // no name\n}\n\n// after (use argumentSet)\n@ParameterizedTest(name = \"{argumentSetName}\")\n@MethodSource(\"provider\")\nvoid test(int x) { }\nstatic Stream<Arguments> provider() {\n    return Stream.of(Arguments.argumentSet(\"positive\", 1));\n}","handlingStrategy":"validation","validationCode":"// Use the safe alternative placeholder that falls back gracefully:\n@ParameterizedTest(name = ParameterizedInvocationConstants.ARGUMENT_SET_NAME_OR_ARGUMENTS_WITH_NAMES_PLACEHOLDER)\n// Or, if {argumentSetName} is used, ensure Arguments.argumentSet() is called:\nstatic Stream<Arguments> provider() {\n    return Stream.of(Arguments.argumentSet(\"positive\", 1, 2));\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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}"],"tags":["parameterized-test","display-name","argument-set","configuration","junit-jupiter-params"],"analyzedSha":"956246301e03d757539f7b76dd5a91f298637563","analyzedAt":"2026-08-04T19:25:17.049Z","schemaVersion":2}