junit-team/junit5 · error · UnsupportedOperationException
Please implement provideArguments(ParameterDeclarations, Ext
Error message
Please implement provideArguments(ParameterDeclarations, ExtensionContext) instead.
What it means
Thrown by the deprecated default provideArguments(ExtensionContext) in the ArgumentsProvider interface (UnsupportedOperationException). It is reached when a custom ArgumentsProvider overrides neither the current 2-arg nor the legacy 1-arg method. Normally the 2-arg default catches this and rewraps it (see error 63), so end users usually see 63 instead.
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 956246301e)
Solutions
- Implement `Stream<? extends Arguments> provideArguments(ParameterDeclarations parameters, ExtensionContext context)` in the provider.
- If extending AnnotationBasedArgumentsProvider, override the 3-arg variant instead.
- Upgrade or pin JUnit to match the provider's expected contract.
Example fix
// before
class MyProvider implements ArgumentsProvider { }
// after
class MyProvider implements ArgumentsProvider {
@Override
public Stream<? extends Arguments> provideArguments(
ParameterDeclarations parameters, ExtensionContext context) {
return Stream.of(Arguments.of(1, 2));
}
} Defensive patterns
Strategy: validation
Validate before calling
// Assert a custom ArgumentsProvider implements the current 2-arg contract.
Class<? extends ArgumentsProvider> provider = MyProvider.class;
boolean ok = Arrays.stream(provider.getMethods())
.anyMatch(m -> m.getName().equals("provideArguments")
&& m.getParameterCount() == 2
&& !m.isDefault());
if (!ok) {
throw new IllegalStateException(provider.getName()
+ " must override provideArguments(ParameterDeclarations, ExtensionContext)");
} Try / catch
try {
// execute the parameterized test
} catch (UnsupportedOperationException e) {
if (e.getMessage().contains("implement provideArguments")) {
// add the 2-arg override to the provider
} else throw e;
} Prevention
- Always override provideArguments(ParameterDeclarations, ExtensionContext) in custom providers.
- Use @Override so the compiler rejects missing/incorrect signatures.
- Keep providers' JUnit version aligned with the runtime version.
When it happens
Trigger: A custom ArgumentsProvider registered via @ArgumentsSource that provides no implementation of provideArguments; the 2-arg default delegates to the 1-arg default which throws UnsupportedOperationException.
Common situations: Newly created provider with an empty body; IDE auto-generated stubs that did not fill the method; upgrade from a pre-5.13 JUnit where the 1-arg method was the interface contract.
Related errors
- AnnotationBasedArgumentsProvider does not override the provi
- ArgumentsProvider does not override the provideArguments(Par
- %s cannot convert to type [%s]. Only target type [%s] is sup
- Failed to parse CSV input configured via ${annotation}
- The charset supplied in ${csvFileSource} is invalid
AI-assisted analysis of junit-team/junit5@956246301e (2026-08-04).
Data as JSON: /data/errors/994e7429add32343.json.
Report an issue: GitHub.