junit-team/junit5 · error · JUnitException
ArgumentConverter does not override the convert(Object, Fiel
Error message
ArgumentConverter does not override the convert(Object, FieldContext) method. Please report this issue to the maintainers of %s.
What it means
Thrown by the default method ArgumentConverter.convert(Object, FieldContext) when a custom ArgumentConverter implementation is used via @ConvertWith on a @Parameter-annotated field (not a method parameter) but the converter 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 conversion in @ParameterizedClass. The %s placeholder is filled with the converter's actual class name.
Source
Thrown at junit-jupiter-params/src/main/java/org/junit/jupiter/params/converter/ArgumentConverter.java:90
@Nullable
Object convert(@Nullable Object source, ParameterContext context) throws ArgumentConversionException;
/**
* Convert the supplied {@code source} object according to the supplied
* {@code context}.
*
* @param source the source object to convert; may be {@code null}
* @param context the field context where the converted object will be
* injected; never {@code null}
* @return the converted object; may be {@code null} but only if the target
* type is a reference type
* @throws ArgumentConversionException if an error occurs during the
* conversion
* @since 5.13
*/
@API(status = EXPERIMENTAL, since = "6.0")
default @Nullable Object convert(@Nullable Object source, FieldContext context) throws ArgumentConversionException {
throw new JUnitException("""
ArgumentConverter does not override the convert(Object, FieldContext) method. \
Please report this issue to the maintainers of %s.""".formatted(getClass().getName()));
}
}
View on GitHub (pinned to f070c699a0)
Solutions
- Override the convert(Object source, FieldContext context) method in your ArgumentConverter implementation
- If the conversion logic is the same regardless of context, delegate from the FieldContext overload to your existing convert logic
- Alternatively, extend SimpleArgumentConverter or TypedArgumentConverter which handle the context delegation internally
- If you don't need field-level conversion, use the converter only on method parameters
Example fix
// before — only overrides ParameterContext variant
public class MyConverter implements ArgumentConverter {
@Override
public Object convert(Object source, ParameterContext context) {
return convertValue(source);
}
}
// after — also override FieldContext variant
public class MyConverter implements ArgumentConverter {
@Override
public Object convert(Object source, ParameterContext context) {
return convertValue(source);
}
@Override
public Object convert(Object source, FieldContext context) {
return convertValue(source);
}
private Object convertValue(Object source) { ... }
}
// OR — extend SimpleArgumentConverter for simpler cases
public class MyConverter extends SimpleArgumentConverter {
@Override
public Object convert(Object source, Class<?> targetType) { ... }
} Defensive patterns
Strategy: validation
Validate before calling
// Check if an ArgumentConverter supports field-level conversion
import org.junit.jupiter.params.converter.ArgumentConverter;
static boolean isFieldOverloadOverridden(Class<? extends ArgumentConverter> convClass) {
try {
var m = convClass.getMethod("convert",
Object.class,
org.junit.jupiter.params.support.FieldContext.class);
return m.getDeclaringClass() != ArgumentConverter.class;
} catch (NoSuchMethodException e) { return false; }
}
// Usage: if (!isFieldOverloadOverridden(MyConverter.class)) { /* warn or restrict to method params */ } Prevention
- When upgrading to JUnit 5.13+, audit all custom ArgumentConverter implementations and add the FieldContext overload if used with @Parameter fields
- Prefer extending SimpleArgumentConverter or TypedArgumentConverter which handle both context variants internally
- Run a quick smoke test on every converter with a @ParameterizedClass field to catch missing overloads
When it happens
Trigger: Implement ArgumentConverter and use it with @ConvertWith on a @Parameter field in a @ParameterizedClass, but only override the older convert(Object, ParameterContext) method. The framework calls the FieldContext overload for field-based conversion, hits the default, and throws.
Common situations: Existing custom ArgumentConverter implementations written before JUnit 5.13 being reused with @ParameterizedClass field-level @Parameter annotations after upgrading JUnit. Developers extending SimpleArgumentConverter (which only needs target type) and expecting it to work for fields without realizing the FieldContext path requires explicit implementation.
Related errors
- ArgumentsAggregator does not override the convert(ArgumentsA
- Failed to find constructor for %s [%s]. Please ensure that a
- Cannot convert null to primitive value of type %s
- No built-in converter for source type %s and target type %s
- Cannot convert null to %s; consider setting 'nullable = true
AI-assisted analysis of junit-team/junit5@f070c699a0 (2026-08-11).
Data as JSON: /api/errors/3f6dd6c86c7bc46c.
Report an issue: GitHub.