junit-team/junit5 · error · JUnitException

AnnotationBasedArgumentsProvider does not override the…

Error message

AnnotationBasedArgumentsProvider does not override the provideArguments(ParameterDeclarations, ExtensionContext, Annotation) method. Please report this issue to the maintainers of %s.

What it means

Thrown by the deprecated protected provideArguments(ExtensionContext, A) in AnnotationBasedArgumentsProvider when a subclass has not overridden the new provideArguments(ParameterDeclarations, ExtensionContext, Annotation) method introduced in 5.13. The base default now only signals that the subclass must migrate to the new signature. The message asks the user to report the issue to the maintainers of the offending class.

Solutions

  1. Override provideArguments(ParameterDeclarations, ExtensionContext, Annotation) in the AnnotationBasedArgumentsProvider subclass.
  2. Upgrade the third-party extension library to a version compatible with JUnit 5.13+.
  3. If the subclass is from a library you do not control, file an issue with the maintainers as the message instructs, using the printed class name.

Example fix

// before
@Override
protected Stream<? extends Arguments> provideArguments(ExtensionContext ctx, MyAnnotation ann) { ... }

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

Strategy: validation

Validate before calling

// Reflectively verify the subclass overrides the new method before use
boolean overridesNew = Arrays.stream(providerClass.getDeclaredMethods())
    .anyMatch(m -> m.getName().equals("provideArguments")
        && m.getParameterCount() == 3
        && m.getParameters()[0].getType() == ParameterDeclarations.class);
if (!overridesNew) throw new IllegalStateException("Provider must override the new provideArguments");

Prevention

When it happens

Trigger: A third-party or custom AnnotationBasedArgumentsProvider subclass overrides only the old 2-arg provideArguments(ExtensionContext, A). When the framework calls the new 3-arg method, the default falls through to the deprecated 2-arg method which throws this JUnitException.

Common situations: Upgrading JUnit Jupiter to 5.13+ while using a custom or library-provided ArgumentsProvider that extends AnnotationBasedArgumentsProvider and has not been updated. Using an outdated third-party extension built against pre-5.13 APIs.

Related errors


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

Appendix: source

Thrown at junit-jupiter-params/src/main/java/org/junit/jupiter/params/provider/AnnotationBasedArgumentsProvider.java:79

	public Stream<? extends Arguments> provideArguments(ParameterDeclarations parameters, ExtensionContext context) {
		return annotations.stream().flatMap(annotation -> provideArguments(parameters, context, annotation));
	}

	/**
	 * Provide a {@link Stream} of {@link Arguments} &mdash; based on metadata in the
	 * provided annotation &mdash; to be passed to a {@code @ParameterizedTest} method.
	 *
	 * @param context the current extension context; never {@code null}
	 * @param annotation the annotation to process; never {@code null}
	 * @return a stream of arguments; never {@code null}
	 * @deprecated Please implement
	 * {@link #provideArguments(ParameterDeclarations, ExtensionContext, Annotation)}
	 * instead.
	 */
	@Deprecated(since = "5.13")
	@API(status = DEPRECATED, since = "5.13")
	protected Stream<? extends Arguments> provideArguments(ExtensionContext context, A annotation) {
		throw new JUnitException("""
				AnnotationBasedArgumentsProvider does not override the \
				provideArguments(ParameterDeclarations, ExtensionContext, Annotation) method. \
				Please report this issue to the maintainers of %s.""".formatted(getClass().getName()));
	}

	/**
	 * The returned {@code Stream} will be {@link Stream#close() properly closed}
	 * by the default implementation of
	 * {@link #provideArguments(ParameterDeclarations, ExtensionContext)},
	 * making it safe to use a resource such as
	 * {@link java.nio.file.Files#lines(java.nio.file.Path) Files.lines()}.
	 */
	protected Stream<? extends Arguments> provideArguments(ParameterDeclarations parameters, ExtensionContext context,
			A annotation) {
		return provideArguments(context, annotation);
	}

}

View on GitHub (pinned to f070c699a0)