junit-team/junit5 · error · ExtensionConfigurationException

Unsupported argument count validation mode: <mode>

Error message

Unsupported argument count validation mode: <mode>

What it means

Thrown by ArgumentCountValidator.validate() when the resolved ArgumentCountValidationMode is not DEFAULT, NONE, or STRICT. The enum has exactly three values and all are handled (DEFAULT and NONE share a case, STRICT has its own), so this default branch is effectively unreachable defensive code that guards against future enum additions.

Source

Thrown at junit-jupiter-params/src/main/java/org/junit/jupiter/params/ArgumentCountValidator.java:52

	ArgumentCountValidator(ParameterizedDeclarationContext<?> declarationContext, EvaluatedArgumentSet arguments) {
		this.declarationContext = declarationContext;
		this.arguments = arguments;
	}

	void validate(ExtensionContext extensionContext) {
		validateRequiredArgumentsArePresent();
		ArgumentCountValidationMode argumentCountValidationMode = getArgumentCountValidationMode(extensionContext);
		switch (argumentCountValidationMode) {
			case DEFAULT, NONE -> {
			}
			case STRICT -> {
				int consumedCount = this.declarationContext.getResolverFacade().determineConsumedArgumentCount(
					this.arguments);
				int totalCount = this.arguments.getTotalLength();
				Preconditions.condition(consumedCount == totalCount,
					() -> wrongNumberOfArgumentsMessages("consumes", consumedCount, null, null));
			}
			default -> throw new ExtensionConfigurationException(
				"Unsupported argument count validation mode: " + argumentCountValidationMode);
		}
	}

	private void validateRequiredArgumentsArePresent() {
		var requiredParameterCount = this.declarationContext.getResolverFacade().getRequiredParameterCount();
		if (requiredParameterCount != null) {
			var totalCount = this.arguments.getTotalLength();
			Preconditions.condition(requiredParameterCount.value() <= totalCount,
				() -> wrongNumberOfArgumentsMessages("has", requiredParameterCount.value(), "required",
					requiredParameterCount.reason()));
		}
	}

	private String wrongNumberOfArgumentsMessages(String verb, int actualCount, @Nullable String parameterAdjective,
			@Nullable String reason) {
		int totalCount = this.arguments.getTotalLength();
		return "Configuration error: @%s %s %s %s%s%s but there %s %s %s provided.%nNote: the provided arguments were %s".formatted(

View on GitHub (pinned to 956246301e)

Solutions

  1. This error should not occur under normal usage; verify there is no version mismatch between junit-jupiter-params and junit-jupiter-engine
  2. If it appears, file a bug — the switch in ArgumentCountValidator is missing a case for a new enum value
Defensive patterns

Strategy: validation

Validate before calling

// No user validation needed — the enum has exactly 3 values, all handled.
// This branch is unreachable defensive code.
Set<ArgumentCountValidationMode> valid =
    EnumSet.of(ArgumentCountValidationMode.DEFAULT,
               ArgumentCountValidationMode.NONE,
               ArgumentCountValidationMode.STRICT);

Prevention

When it happens

Trigger: Calling validate() with an ArgumentCountValidationMode value outside the three defined enum constants. Since the enum is closed with exactly DEFAULT, NONE, and STRICT, no standard value reaches this branch.

Common situations: Practically never encountered by end users. Would only surface if a future JUnit version added a new ArgumentCountValidationMode without updating the switch.

Related errors


AI-assisted analysis of junit-team/junit5@956246301e (2026-08-04). Data as JSON: /data/errors/1d93ff3e73635dec.json. Report an issue: GitHub.