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

Use JUnit @Nested classes for tests instead of comment sections #2960

Draft
wants to merge 55 commits into
base: version/1.x
Choose a base branch
from

Conversation

bvkatwijk
Copy link
Contributor

@bvkatwijk bvkatwijk commented Jan 3, 2025

Fix #2951

  • Update Generator.sc so that generated tests use @Nested classes
  • Use @Nested classes in all standalone tests
  • Use @Nested classes in inherited tests
    • Not sure if this is possible at the moment - Inheritance and nested classes don't mix well, especially in java 8 which is the current language level
  • Decide on style for @Nested classes
    • Class name sometimes clashes with other class names, so I appended Test and used @DisplayName

Notes:

  • Used a script to do some bulk refactoring (sed may behave differently across OSes):
find ./src -name "*Test.java" -type f -exec sed -E -i '' \
    's|// -- ([a-zA-Z0-9]+)$|}\n\n    @Nested\n    @DisplayName("\1")\n    class \CAPS\1Test {|' {} +
find ./src -type f -name '*Test.java' -exec perl -i -pe 's/\bCAPS([a-zA-Z])([a-zA-Z]*)/\u\1\2/g' {} +

Copy link

codecov bot commented Jan 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.74%. Comparing base (e43e44b) to head (1feab74).
Report is 85 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #2960   +/-   ##
=========================================
  Coverage     92.74%   92.74%           
- Complexity     5247     5262   +15     
=========================================
  Files            89       89           
  Lines         12538    12552   +14     
  Branches       1604     1598    -6     
=========================================
+ Hits          11628    11641   +13     
- Misses          721      723    +2     
+ Partials        189      188    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


class ClzMatch {}
class ClzMatch1 extends ClzMatch {}
class ClzMatch2 extends ClzMatch {}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed these to non-static since static inner classes are not supported in JDK 8

This reverts commit fcdf049.
@pivovarit
Copy link
Member

note: there's now main branch, which is ex-version/0.x - for now, there's no reason to target version/1.x

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.

Use @Nested classes instead of comments for grouping tests
2 participants