Skip to content

Support object field access for ParameterizedTest's name #2572

@Phlegethonyarre

Description

@Phlegethonyarre

@ParameterizedTest(name = "...") provides feature to get it's argument value into it's name by using '{0}'.

The common use is that i want to use an Object within an argument (for example User).
In this case i have to go with providing another string argument into test source, that looks like
@ParameterizedTest(name = "I am testing user with name {0}")
void testUser(String userName, User user) {
...
}

But what people need is provide only User argument and access needed field through name (user.getName() or user.name):
@ParameterizedTest(name = "I am testing user with name user.name")
void testUser(User user) {
...
}

Please allow us to do this <3

Activity

sbrannen

sbrannen commented on Mar 17, 2021

@sbrannen
Member

Closing as a duplicate of #1154.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @sbrannen@Phlegethonyarre

        Issue actions

          Support object field access for ParameterizedTest's name · Issue #2572 · junit-team/junit-framework