Skip to content
Latchkey

JUnit 5 "must declare at least one ArgumentsSource" - Fix

A JUnit 5 @ParameterizedTest ran with no argument source. Either you forgot the @ValueSource/@MethodSource/@CsvSource annotation, or junit-jupiter-params is not on the test classpath so the parameterized infrastructure is absent.

What this error means

The test errors (not fails) with Configuration error: You must configure at least one set of arguments for this @ParameterizedTest or org.junit.jupiter.params... cannot be found. The method is detected but cannot be supplied inputs.

junit
org.junit.jupiter.api.extension.ParameterResolutionException:
Configuration error: You must configure at least one set of arguments for
this @ParameterizedTest
	at org.junit.jupiter.params.ParameterizedTestExtension...

Diagnose it: resolve the effective POM first

Maven merges parent POMs, profiles, and settings before it builds anything. The configuration causing your failure is frequently inherited or activated by a profile that is on locally and off in CI.

Terminal
# the fully resolved configuration Maven will actually use
mvn help:effective-pom | head -60

# which profiles are active here vs on your machine?
mvn help:active-profiles

# full error, offline-safe, no colour codes to confuse the log
mvn -B -e -X <goal> 2>&1 | tail -60

Common causes

No arguments-source annotation

The method is @ParameterizedTest but lacks @ValueSource/@MethodSource/@CsvSource, so JUnit has nothing to feed it.

junit-jupiter-params not on the classpath

Only junit-jupiter-api was added; the params module that provides parameterized support is missing.

A @MethodSource that resolves to nothing

The referenced factory method returns an empty stream or is not static/visible, so no arguments are produced.

How to fix it

Add an arguments source

Provide the inputs the parameterized test consumes.

java
@ParameterizedTest
@ValueSource(ints = {1, 2, 3})
void isPositive(int n) { assertTrue(n > 0); }

Add junit-jupiter-params

Ensure the params module is on the test classpath.

gradle
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.11.0'

Fix a @MethodSource factory

Make the factory static and ensure it returns a non-empty stream.

java
static Stream<Arguments> cases() {
  return Stream.of(Arguments.of(1, "a"), Arguments.of(2, "b"));
}

How to prevent it

  • Always pair @ParameterizedTest with an explicit arguments source.
  • Include junit-jupiter-params alongside the API and engine.
  • Keep @MethodSource factories static and non-empty.

Frequently asked questions

What causes JUnit 5 "must declare at least one ArgumentsSource"?
There are 3 common causes: no arguments-source annotation, junit-jupiter-params not on the classpath, and a @methodsource that resolves to nothing. The method is @ParameterizedTest but lacks @ValueSource/@MethodSource/@CsvSource, so JUnit has nothing to feed it.
How do I fix JUnit 5 "must declare at least one ArgumentsSource"?
There are 3 fixes depending on which cause you have: add an arguments source, add junit-jupiter-params, and fix a @methodsource factory. Work through them in order, since the first is the most common.
What does JUnit 5 "must declare at least one ArgumentsSource" actually mean?
The test errors (not fails) with Configuration error: You must configure at least one set of arguments for this @ParameterizedTest or org.junit.jupiter.params...
How do I stop JUnit 5 "must declare at least one ArgumentsSource" happening again?
Always pair @ParameterizedTest with an explicit arguments source. The prevention section lists 3 changes that keep it from recurring.

Related guides

References

Not every red build is your code. Latchkey repairs the ones that are not, on the runner. Start free → 30-day trial · No credit card