-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Introduce SPI for generating display names #162
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
Comments
how about making 'prettify' the default action when no explicit name is given? |
I like the proposal from @schauder, and I have changed the title of this issue accordingly. @junit-team/junit-lambda, what does the rest of the team think about making this change? |
I like the idea and also support going forward into this direction. We should discuss in detail what prettify exactly means as we somehow set a standard for naming test methods and I know there are different styles in the community: https://dzone.com/articles/7-popular-unit-test-naming With this change we might make a statement which style should be used as we support it the best. We simply should keep that in mind as we move on. Still, I support this change. |
I'd rather not have prettification as default because there'll always be some corner cases (eg. acronyms and abbreviations) where any automatic prettification scheme will fail. |
I agree with @bechte about the different testing styles and the corner cases mentioned by @jlink. I'd prefer not having this complexity and ‘one size fits all’ naming convention in junit core. How about providing an ExtensionPoint to provide the display name? |
Two edges to this sword:
YMMV but my experience often shows that more people will find and follow bad examples than the good ones. I fear the most common usage we'll end up seeing is where the display names basically repeat what the method name already says. Goodbye DRY, now we're WET (Writing Everything Twice) all over the place. The link to the bad examples a JavaOne 2016 presentation stream, the relevant segment was given by folks from Penn State University, starting at the 06:17:00 mark. To think that these are the kind of examples that future authors of JUnit tests will learn from makes me shudder. I also would humbly point out that the JUnit 5 user guide doesn't have very good examples either. I like the idea of automatically prettifying the names for the report through an ExtensionPoint. Are there really that many corner cases where auto-prettify would get tripped up? My teams' test naming convention follows Neal Ford's style, using underscores to separate words so an extension that auto replaces "_" with " " would have a very high, if not perfect, success rate. |
In light of recent team discussions, I have renamed this issue to focus on the introduction of a new extension for generating display names. |
FYI: I have added a Deliverables section to this issue's description. |
Regarding the camel-case converter, searching the Internet reveals lots of discussions around this topic -- for example, https://stackoverflow.com/questions/2559759/how-do-i-convert-camelcase-into-human-readable-names-in-java/2560017#2560017 |
Thanks for the review and feedback, Sam. Pushed a second spike to #1588. |
Actually, the more I think about it (and after having looked at the latest updates @sormuras made to his PR), I think we are actually implementing the Decorator pattern with our styles. This leads to the following, treating style names as functions.
So that means that the camel-case display name generator would automatically convert underscores to spaces simply be delegating to the underscore style which in turn delegates to the default style. |
In many cases the strings passed to
@DisplayName
are just a prettified version of the class/method name, e.g.:It might be a nice-to-have if this could happen automatically, e.g.:
Related Issues
Deliverables
The text was updated successfully, but these errors were encountered: