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

ParameterizedTests with a name attribute are not being properly handled #33

Open
bitcoder opened this issue Apr 6, 2023 · 3 comments
Open

Comments

@bitcoder
Copy link
Collaborator

bitcoder commented Apr 6, 2023

Parameterized tests can be annotated with @ParameterizedTest; additionaly, it's possible to specify a custom name for each parameterized test.

    @ParameterizedTest(name="#{index} - Test with Argument={0}")
    @ValueSource(strings = {"John Doe", "Jimi Hendrix"})
    public void parameterizedTestWithCustomName(String name)
    {
       // ...
    }

When the name is defined, it can even mention the DisplayName in case that annotation has also been used.

    @DisplayName("custom DisplayName")
    @ParameterizedTest(name="{displayName}: #{index} - Test with Argument={0}")
    @ValueSource(strings = {"John Doe", "Jimi Hendrix"})
    public void parameterizedTestWithCustomNameAndDisplayName(String name)
    {
        fail("test failed on purpose");
    }

The executed tests should produce different testcases with proper test_summary properties.
For the time being, the testcases will be identified by the same name, but each one will have a specific test_summary property using the name defined with the @ParameterizedTest annotation and its name attribute.

@bitcoder
Copy link
Collaborator Author

To evaluate: should the displayname, in any/some cases, be mapped to the <testcase> name attribute?

@nmoreira
Copy link

Any plans for a release with this fix?
It would be much appreciated.

@bitcoder
Copy link
Collaborator Author

Any plans for a release with this fix?
It would be much appreciated.

Not yet. This needs some additional thought and more testing.
You can try the code on the fix attempt and see how it works for you. Feedback and testing is highly appreciated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants