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

Simplify unit test display names #82

Closed
KyleAure opened this issue Nov 16, 2022 · 4 comments
Closed

Simplify unit test display names #82

KyleAure opened this issue Nov 16, 2022 · 4 comments
Assignees
Labels
good first issue Good for newcomers

Comments

@KyleAure
Copy link
Contributor

Many of the unit tests for the API use a display name that matches the method name like in this example:

@Test
@DisplayName("Should create pageable with size")
void shouldCreatePageableWithSize() {
Pageable pageable = Pageable.ofSize(50);
assertSoftly(softly -> {
softly.assertThat(pageable.page()).isEqualTo(1L);
softly.assertThat(pageable.size()).isEqualTo(50);
});
}

Instead, we could use the @DisplayNameGeneration annotation on the class to automatically give tests displays names based on the test method name.

For example:

@DisplayNameGeneration(ReplaceCamelCase.class)
class LimitTest {
    @Test
    void shouldReturnErrorWhen_maxResults_IsNegative() {
      ...
    }
    @Test
    void shouldCreateLimitWithRange() {
      ...
    }
}

This would result in display names of:

- Should return error when maxResults is negative
- Should create limit with range
@FanJups
Copy link

FanJups commented Aug 16, 2023

Good idea, I will work on it.

@KyleAure KyleAure added the good first issue Good for newcomers label Aug 23, 2023
@KyleAure
Copy link
Contributor Author

Closing not appropriate for this project to handle.

@FanJups
Copy link

FanJups commented Nov 21, 2023

I just opened a new JUnit issue to handle this case junit-team/junit5#3569

@FanJups
Copy link

FanJups commented Dec 9, 2023

JUnit Pioneer plans to integrate this feature but they are waiting the decision of JUnit

junit-pioneer/junit-pioneer#793

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

Successfully merging a pull request may close this issue.

2 participants