Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document that ParameterizedTest passes raw arguments to MessageFormat #2398

Closed
johnsoneal opened this issue Sep 6, 2020 · 1 comment
Closed

Comments

@johnsoneal
Copy link

johnsoneal commented Sep 6, 2020

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.

@marcphilipp
Copy link
Member

Team decision: Clarify the current behavior in the Javadoc for now. Revisit providing raw and converted argument in #1154.

@marcphilipp marcphilipp added this to the 5.7 GA milestone Sep 11, 2020
@marcphilipp marcphilipp changed the title ParameterizedTest name pattern arguments are those before any conversions. Document that ParameterizedTest passes raw arguments to MessageFormat Sep 12, 2020
@marcphilipp marcphilipp self-assigned this Sep 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants