junit-team/junit5 · error · UnsupportedOperationException

Please implement provideArguments(ParameterDeclarations…

Error message

Please implement provideArguments(ParameterDeclarations, ExtensionContext) instead.

What it means

Thrown by the deprecated default method provideArguments(ExtensionContext) on the ArgumentsProvider interface. Since 5.13 the contract requires implementing provideArguments(ParameterDeclarations, ExtensionContext); the old default now throws UnsupportedOperationException to signal that it must not be relied on. This surfaces only when an ArgumentsProvider does not implement the new method.

Solutions

  1. Implement provideArguments(ParameterDeclarations, ExtensionContext) in the ArgumentsProvider.
  2. Upgrade or replace third-party ArgumentsProvider implementations with versions targeting JUnit 5.13+.
  3. If you only had the old method, rename/rewrite its signature to the new parameterized form.

Example fix

// before
@Override
public Stream<? extends Arguments> provideArguments(ExtensionContext ctx) { ... }

// after
@Override
public Stream<? extends Arguments> provideArguments(ParameterDeclarations params, ExtensionContext ctx) { ... }
Defensive patterns

Strategy: validation

Validate before calling

// Confirm the provider implements the new signature
boolean hasNew = Arrays.stream(providerClass.getMethods())
    .anyMatch(m -> m.getName().equals("provideArguments")
        && m.getParameterCount() == 2
        && !m.isDefault());
if (!hasNew) throw new IllegalStateException("ArgumentsProvider must implement provideArguments(ParameterDeclarations, ExtensionContext)");

Prevention

When it happens

Trigger: An ArgumentsProvider implementation does not override provideArguments(ParameterDeclarations, ExtensionContext). The framework's default bridge calls the deprecated provideArguments(ExtensionContext), whose default body throws UnsupportedOperationException.

Common situations: Custom ArgumentsProvider written against pre-5.13 API after upgrading JUnit. Library-provided provider that has not migrated to the new signature.

Related errors


AI-assisted analysis of junit-team/junit5@f070c699a0 (2026-08-11). Data as JSON: /api/errors/994e7429add32343. Report an issue: GitHub.

Appendix: source

Thrown at junit-jupiter-params/src/main/java/org/junit/jupiter/params/provider/ArgumentsProvider.java:61

 * @see org.junit.jupiter.params.support.AnnotationConsumer
 */
@API(status = STABLE, since = "5.7")
public interface ArgumentsProvider {

	/**
	 * Provide a {@link Stream} of {@link Arguments} to be passed to a
	 * {@code @ParameterizedTest} method.
	 *
	 * @param context the current extension context; never {@code null}
	 * @return a stream of arguments; never {@code null}
	 * @deprecated Please implement
	 * {@link #provideArguments(ParameterDeclarations, ExtensionContext)} instead.
	 */
	@Deprecated(since = "5.13")
	@API(status = DEPRECATED, since = "5.13")
	default Stream<? extends Arguments> provideArguments(@SuppressWarnings("unused") ExtensionContext context)
			throws Exception {
		throw new UnsupportedOperationException(
			"Please implement provideArguments(ParameterDeclarations, ExtensionContext) instead.");
	}

	/**
	 * Provide a {@link Stream} of {@link Arguments} to be passed to a
	 * {@code @ParameterizedClass} or {@code @ParameterizedTest}.
	 *
	 * @param parameters the parameter declarations for the parameterized
	 * class or test; never {@code null}
	 * @param context the current extension context; never {@code null}
	 * @return a stream of arguments; never {@code null}
	 * @since 5.13
	 */
	@API(status = MAINTAINED, since = "6.0.2")
	default Stream<? extends Arguments> provideArguments(ParameterDeclarations parameters, ExtensionContext context)
			throws Exception {
		try {
			return provideArguments(context);

View on GitHub (pinned to f070c699a0)