Skip to content

Document that ParameterizedTest passes raw arguments to MessageFormat #2398

@johnsoneal

Description

@johnsoneal

The ParameterizedTest name states the supported placeholder "{0}, {1}, etc.: an individual argument (0-based)" may be formatted with a MessageFormat pattern, "For the latter, you may use java.text.MessageFormat patterns to customize formatting." However, the argument passed to the pattern are not the arguments the method excepts but the argument supplied by the argument provider.

This can be seen in this silly test:

    @ParameterizedTest(name = "{0,number,#.00}")
    @ValueSource(ints = { 10, 20 })
    @CsvSource(value = { "30", "40" })
    void silly(double value)
    {
        // ValueSource - OK
        // CsvSource - FAILS with Exception
    }

It seems that the format is called before any conversation, whether implicit or explicit.

Not sure if this is a bug as such but the documentation should specify what argument is formated.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions