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

Add new DisplayNameGenerator ReplaceCamelCaseAndUnderscoreAndNumber #819

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

FanJups
Copy link

@FanJups FanJups commented May 18, 2024

This extension handles method names with CamelCase, underscore and numbers.

The aim is to simplify unit test display names. Instead of using this method annotation org.junit.jupiter.api.DisplayName on every method, we can just use this class annotation org.junit.jupiter.api.DisplayNameGeneration and use that method annotation if needed.

This generator follows 3 rules:

  • Each uppercase letter is turned into its lowercase value prepended by space.
  • Each underscore is turned into space. Words bounded by underscores or just starting with underscore are not transformed. Usually these words represent classes, variables...
  • Each number is prepended by space.

Closes: #793
PR: #819


PR checklist

The following checklist shall help the PR's author, the reviewers and maintainers to ensure the quality of this project.
It is based on our contributors guidelines, especially the "writing code" section.
It shall help to check for completion of the listed points.
If a point does not apply to the given PR's changes, the corresponding entry can be simply marked as done.

Documentation (general)

  • There is documentation (Javadoc and site documentation; added or updated)
  • There is implementation information to describe why a non-obvious source code / solution got implemented
  • Site documentation has its own .adoc file in the docs folder, e.g. docs/report-entries.adoc
  • Site documentation in .adoc file references demo in src/demo/java instead of containing code blocks as text
  • Only one sentence per line (especially in .adoc files)
  • Javadoc uses formal style, while sites documentation may use informal style

Documentation (new extension)

  • The docs/docs-nav.yml navigation has an entry for the new extension
  • The package-info.java contains information about the new extension

Code (general)

  • Code adheres to code style, naming conventions etc.
  • Successful tests cover all changes
  • There are checks which validate correct / false usage / configuration of a functionality and there are tests to verify those checks
  • Tests use AssertJ or our own PioneerAssert (which are based on AssertJ)

Code (new package)

  • The new package is exported in module-info.java
  • The new package is also present in the tests
  • The new package is opened for reflection to JUnit 5 in module-info.java
  • The new package is listed in the contribution guide

Contributing

  • A prepared commit message exists
  • The list of contributions inside README.adoc mentions the new contribution (real name optional)

@FanJups FanJups marked this pull request as draft May 18, 2024 21:21
…unit-pioneer#793 / junit-pioneer#819)

This extension handles method names with CamelCase, underscore and numbers.

The aim is to simplify unit test display names. Instead of using this method annotation org.junit.jupiter.api.DisplayName on every method, we can just use this class annotation org.junit.jupiter.api.DisplayNameGeneration and use that method annotation if needed.

 This generator follows 3 rules:

 - Each uppercase letter is turned into its lowercase value prepended by space.
 - Each underscore is turned into space. Words bounded by underscores or just starting with underscore are not transformed. Usually these words represent classes, variables...
 - Each number is prepended by space.

Closes: junit-pioneer#793
PR: junit-pioneer#819
@FanJups FanJups force-pushed the issue/793-displaynamegenerator-camelcase-underscore-number branch from 6000d30 to 4afa546 Compare May 18, 2024 21:26
@Michael1993
Copy link
Member

Personally, I'd prefer to review this when the build is passing - if you need help, let us know.

@FanJups
Copy link
Author

FanJups commented May 20, 2024

Personally, I'd prefer to review this when the build is passing - if you need help, let us know.

Sure, thanks. I am trying to test @DisplayNameGeneration(ReplaceCamelCaseAndUnderscoreAndNumber.class) but my test failed.

That's why it's still in draft mode.

@FanJups
Copy link
Author

FanJups commented May 21, 2024

Personally, I'd prefer to review this when the build is passing - if you need help, let us know.

Sure, thanks. I am trying to test @DisplayNameGeneration(ReplaceCamelCaseAndUnderscoreAndNumber.class) but my test failed.

That's why it's still in draft mode.

Maybe, its because the generator is not well configured. The first test is green but the 2nd one simulating a real scenario does not.

@FanJups
Copy link
Author

FanJups commented Jun 7, 2024

Hi @Michael1993 , please are available these days for a call ?

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

Successfully merging this pull request may close these issues.

Introduce DisplayNameGenerator to support CamelCase, underscores, and numbers
2 participants