JUnit Jupiter best practices#91
Merged
slachiewicz merged 1 commit intocodehaus-plexus:masterfrom Nov 3, 2025
Merged
Conversation
5d95770 to
f0db9f7
Compare
Co-authored-by: Moderne <[email protected]>
f0db9f7 to
4ec3931
Compare
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
Missing diamond operator '<>' for HashMap instantiation. Should be 'new HashMap<>()' to be consistent with other modernizations in this PR.
Suggested change
| Map<String, String> context = new HashMap(); | |
| Map<String, String> context = new HashMap<>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use this link to re-run the recipe: https://app.moderne.io/recipes/org.openrewrite.java.testing.junit.JupiterBestPractices?organizationId=NzQ1YmJlODUtZjNkMy00OTNkLThhNDAtZWJmZDg4N2U1ZjU1