-
Notifications
You must be signed in to change notification settings - Fork 12
JUnit Jupiter best practices #91
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
JUnit Jupiter best practices #91
Conversation
5d95770 to
f0db9f7
Compare
Co-authored-by: Moderne <[email protected]>
f0db9f7 to
4ec3931
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request modernizes JUnit test code across multiple test classes by adopting Java 8+ language features and JUnit 5 conventions. The changes improve code readability and maintainability while standardizing test naming patterns.
- Updated test class and method visibility from public to package-private (removing public modifier)
- Renamed test methods to remove "test" prefix following JUnit 5 naming conventions
- Simplified exception declarations from specific exceptions to generic
Exception - Modernized Java syntax using diamond operators for generic type inference
- Converted anonymous classes to lambda expressions where applicable
- Removed unnecessary wrapper calls (e.g.,
Collections.unmodifiableList(Collections.singletonList(...))toCollections.singletonList(...)) - Cleaned up unused imports
- Made fields final where appropriate
Reviewed Changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| StringUtilsTest.java | Updated class/method visibility and naming |
| FieldBasedObjectInterpolatorTest.java | Modernized syntax with diamond operators, removed redundant Collections wrapper, updated visibility/naming |
| MultiDelimiterStringSearchInterpolatorTest.java | Simplified exceptions, added diamond operators, lambda conversions, removed unused imports, updated naming |
| MultiDelimiterInterpolatorFilterReaderTest.java | Comprehensive modernization including lambdas, diamond operators, updated visibility/naming |
| FixedStringSearchInterpolatorTest.java | Lambda conversions, diamond operators, simplified exceptions, made field final, updated naming |
| EnvarBasedValueSourceTest.java | Lambda conversions, diamond operators, removed license header, updated naming |
| StringSearchInterpolatorTest.java | Extensive modernization including lambdas, diamond operators, made field final, removed license header |
| RegexBasedInterpolatorTest.java | Lambda conversions, diamond operators, removed license header, updated naming |
| PropertiesBasedValueSourceTest.java | Updated visibility and naming |
| PrefixedValueSourceWrapperTest.java | Updated visibility and naming |
| PrefixedObjectValueSourceTest.java | Updated visibility, naming, and diamond operators |
| PrefixAwareRecursionInterceptorTest.java | Updated visibility, naming, and removed unnecessary array wrapper |
| InterpolatorFilterReaderTest.java | Updated visibility, naming, and diamond operators |
| FeedbackingValueSourceTest.java | Updated visibility, naming, and simplified exceptions |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| RegexBasedInterpolator rbi = new RegexBasedInterpolator(); | ||
|
|
||
| Map context = new HashMap(); | ||
| Map<String, String> context = new HashMap(); |
Copilot
AI
Nov 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing diamond operator '<>' for HashMap instantiation. Should be 'new HashMap<>()' to be consistent with other modernizations in this PR.
| Map<String, String> context = new HashMap(); | |
| Map<String, String> context = new HashMap<>(); |
Use this link to re-run the recipe: https://app.moderne.io/recipes/org.openrewrite.java.testing.junit.JupiterBestPractices?organizationId=NzQ1YmJlODUtZjNkMy00OTNkLThhNDAtZWJmZDg4N2U1ZjU1