Skip to content

Parameter table ignores JUnit Named display value in parameterized tests #162

Description

@paul-brooks

The test header correctly shows the Named.of("display", payload) display name, but the parameter table shows the raw payload.

Root cause

Two different sources; only one sees Named:

  • Header (correct): uses ExtensionContext.displayName, which JUnit pre-formats via Named.getName() (KensaExtension.ktJsonTransforms.kt:73).
  • Parameter table (wrong): built from invocationContext.arguments, which JUnit has already unwrapped to payloads at the resolver boundary (ResolverFacade.getConsumedPayload). Kensa indexes positionally in ParameterElementDescriptor.resolveValue (ElementDescriptor.kt:66) → NamedValue(name, rawPayload)JsonTransforms.kt:64.

No code references org.junit.jupiter.params.provider.Named anywhere. The Named wrapper is gone before Kensa captures.

Feasibility

No public JUnit hook exposes the Named wrapper at capture time. EvaluatedArgumentSet retains it (getConsumedNames()) but is package-private and never stored; the public ParameterInfo accessor yields payloads only.

  • Option A (recommended, medium): parse per-parameter names out of context.displayName (the {argumentsWithNames} formatter already renders getConsumedNames()[i]), correlate positionally with captured payloads, substitute the Named name. No reflection, no user test changes. Fragile only for custom @ParameterizedTest(name=...) patterns → fall back to payload toString().
  • Option B (rejected, hard): reflect into JUnit-internal EvaluatedArgumentSet — brittle across releases (5.14/6.0 differ). Not worth the maintenance cost.

Scope

frameworks/junit/junit5 (and junit6). Affects the parameter table only; header is unaffected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions