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

Introduce @SentenceFragment for use with IndicativeSentences DisplayNameGenerator #4347

Closed
1 task done
sbrannen opened this issue Feb 26, 2025 · 1 comment
Closed
1 task done

Comments

@sbrannen
Copy link
Member

sbrannen commented Feb 26, 2025

Overview

While updating the Spring Framework test suite after the fixes for #4130 and #4131, I noticed that it's currently not possible to provide a custom display name for a "sentence fragment" for the IndicativeSentences DisplayNameGenerator.

You can of course register a custom DisplayNameGenerator (such as ReplaceUnderscores) to affect how a sentence fragment is generated, but you cannot provide a custom sentence fragment.

If you attempt to use @DisplayName for a sentence fragment, the entire sentence (that would otherwise be generated by the IndicativeSentences DisplayNameGenerator) gets overridden by the value of the @DisplayName.

As a proof of concept, I implemented @SentenceFragment and a corresponding SentenceFragmentDisplayNameGenerator) in this commit for Spring Framework's test suite.

Deliverables

  • Introduce support for @SentenceFragment directly in IndicativeSentences.
@sbrannen sbrannen added this to the 5.13.0-M1 milestone Feb 26, 2025
@sbrannen sbrannen self-assigned this Feb 26, 2025
sbrannen added a commit to sbrannen/junit5 that referenced this issue Feb 26, 2025
sbrannen added a commit to sbrannen/junit5 that referenced this issue Feb 27, 2025
sbrannen added a commit to sbrannen/junit5 that referenced this issue Feb 27, 2025
sbrannen added a commit to sbrannen/junit5 that referenced this issue Feb 27, 2025
sbrannen added a commit to sbrannen/junit5 that referenced this issue Feb 27, 2025
@sbrannen

This comment has been minimized.

sbrannen added a commit to sbrannen/junit5 that referenced this issue Mar 2, 2025
sbrannen added a commit to sbrannen/junit5 that referenced this issue Mar 2, 2025
sbrannen added a commit to sbrannen/junit5 that referenced this issue Mar 2, 2025
sbrannen added a commit to sbrannen/junit5 that referenced this issue Mar 2, 2025
sbrannen added a commit to sbrannen/junit5 that referenced this issue Mar 2, 2025
sbrannen added a commit to sbrannen/junit5 that referenced this issue Mar 2, 2025
Prior to this commit, it was not possible to provide a custom display
name for an individual "sentence fragment" for the IndicativeSentences
DisplayNameGenerator.

Although it is possible to register a custom DisplayNameGenerator (such
as ReplaceUnderscores) to affect how a sentence fragment is generated,
you previously could not provide an entire custom sentence fragment. In
addition, attempting to use @⁠DisplayName for a sentence fragment
results in the entire sentence (that would otherwise be generated by
the IndicativeSentences DisplayNameGenerator) getting overridden by the
value of the @⁠DisplayName for the current test class or test
method.

To address that shortcoming, this commit introduces a new
@⁠SentenceFragment annotation that can be used to specify custom
sentence fragments when using the IndicativeSentences
DisplayNameGenerator.

Closes junit-team#4347
Closes junit-team#4349
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant