junit-team/junit5 · error · JUnitException

ArgumentsAggregator does not override the convert(ArgumentsA

Error message

ArgumentsAggregator does not override the convert(ArgumentsAccessor, FieldContext) method. Please report this issue to the maintainers of %s.

What it means

Thrown by the default method ArgumentsAggregator.aggregateArguments(ArgumentsAccessor, FieldContext) when a custom ArgumentsAggregator implementation is used via @AggregateWith on a @Parameter-annotated field (not a method parameter) but the aggregator does not override the FieldContext-based overload. This overload was added in JUnit 5.13 (API status EXPERIMENTAL, since 6.0) to support field-level aggregation in @ParameterizedClass. The %s placeholder is filled with the aggregator's actual class name.

Source

Thrown at junit-jupiter-params/src/main/java/org/junit/jupiter/params/aggregator/ArgumentsAggregator.java:94

	/**
	 * Aggregate the arguments contained in the supplied {@code accessor} into a
	 * single object.
	 *
	 * @param accessor an {@link ArgumentsAccessor} containing the arguments to be
	 * aggregated; never {@code null}
	 * @param context the field context where the aggregated result is to be
	 * injected; never {@code null}
	 * @return the aggregated result; may be {@code null} but only if the target
	 * type is a reference type
	 * @throws ArgumentsAggregationException if an error occurs during the
	 * aggregation
	 * @since 5.13
	 */
	@API(status = EXPERIMENTAL, since = "6.0")
	default @Nullable Object aggregateArguments(ArgumentsAccessor accessor, FieldContext context)
			throws ArgumentsAggregationException {
		throw new JUnitException("""
				ArgumentsAggregator does not override the convert(ArgumentsAccessor, FieldContext) method. \
				Please report this issue to the maintainers of %s.""".formatted(getClass().getName()));
	}

}

View on GitHub (pinned to f070c699a0)

Solutions

  1. Override the aggregateArguments(ArgumentsAccessor accessor, FieldContext context) method in your ArgumentsAggregator implementation
  2. If the aggregation logic is the same regardless of context, delegate from the FieldContext overload to your existing logic
  3. Alternatively, use the aggregator only on method parameters (where ParameterContext is used) until you update the implementation

Example fix

// before — only overrides ParameterContext variant
public class MyAggregator implements ArgumentsAggregator {
    @Override
    public Object aggregateArguments(ArgumentsAccessor accessor, ParameterContext context) {
        return accessor.getString(0) + accessor.getString(1);
    }
}

// after — also override FieldContext variant for field-level use
public class MyAggregator implements ArgumentsAggregator {
    @Override
    public Object aggregateArguments(ArgumentsAccessor accessor, ParameterContext context) {
        return aggregate(accessor);
    }
    @Override
    public Object aggregateArguments(ArgumentsAccessor accessor, FieldContext context) {
        return aggregate(accessor);
    }
    private String aggregate(ArgumentsAccessor accessor) {
        return accessor.getString(0) + accessor.getString(1);
    }
}
Defensive patterns

Strategy: validation

Validate before calling

// Check if an ArgumentsAggregator supports field-level aggregation
import org.junit.jupiter.params.aggregator.ArgumentsAggregator;
import java.lang.reflect.Method;

static boolean supportsFieldAggregation(Class<? extends ArgumentsAggregator> aggClass) throws Exception {
    Method m = aggClass.getMethod("aggregateArguments",
        org.junit.jupiter.params.support.ArgumentsAccessor.class != null
            ? org.junit.jupiter.params.aggregator.ArgumentsAccessor.class : null,
        org.junit.jupiter.params.support.FieldContext.class);
    return !m.getDeclaringClass().equals(ArgumentsAggregator.class); // overridden?
}

// Simplified: check if the method is overridden
static boolean isFieldOverloadOverridden(Class<? extends ArgumentsAggregator> aggClass) {
    try {
        var m = aggClass.getMethod("aggregateArguments",
            org.junit.jupiter.params.aggregator.ArgumentsAccessor.class,
            org.junit.jupiter.params.support.FieldContext.class);
        return m.getDeclaringClass() != ArgumentsAggregator.class;
    } catch (NoSuchMethodException e) { return false; }
}

Prevention

When it happens

Trigger: Implement ArgumentsAggregator and use it with @AggregateWith on a @Parameter field in a @ParameterizedClass, but only override the older aggregateArguments(ArgumentsAccessor, ParameterContext) method. The framework calls the FieldContext overload for field-based aggregation, hits the default, and throws.

Common situations: Existing custom ArgumentsAggregator implementations written before JUnit 5.13 that are now being used with @ParameterizedClass field-level aggregation. Developers upgrading JUnit versions and attempting to reuse their aggregators in the new field context without updating the implementation.

Related errors


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