Skip to content

Add AssertEqualsIntegralDeltaToAssertEquals recipe#950

Merged
timtebeek merged 3 commits intomainfrom
tim/remove-int-assertEquals-precision
Mar 30, 2026
Merged

Add AssertEqualsIntegralDeltaToAssertEquals recipe#950
timtebeek merged 3 commits intomainfrom
tim/remove-int-assertEquals-precision

Conversation

@timtebeek
Copy link
Copy Markdown
Member

@timtebeek timtebeek commented Mar 30, 2026

Summary

  • Adds a new JUnit best practices recipe that removes the unnecessary delta/precision argument from assertEquals() when both expected and actual are int or long types

  • Integer arguments get upcasted to double when a delta is provided, adding unnecessary complexity

  • Handles both 3-arg (with delta) and 4-arg (with delta + message) variants, and both static import and qualified call styles

  • Registered in JupiterBestPractices recipe list

  • Closes MigrateHamcrestToAssertJ handling of three arg assertEquals with numerical arguments #869

Test plan

  • 8 test cases covering int/long literals, method return values, message variants, qualified imports, and no-change scenarios
  • All cleanup tests pass with no regressions

Remove the unnecessary delta/precision argument from assertEquals when
both expected and actual are int or long types, since the delta is
meaningless for exact integer comparison.
@timtebeek timtebeek merged commit 9ae6e43 into main Mar 30, 2026
1 check passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Mar 30, 2026
@timtebeek timtebeek deleted the tim/remove-int-assertEquals-precision branch March 30, 2026 11:24
sullis pushed a commit to sullis/rewrite-testing-frameworks that referenced this pull request Mar 31, 2026
* Add AssertEqualsIntegralDeltaToAssertEquals recipe (openrewrite#869)

Remove the unnecessary delta/precision argument from assertEquals when
both expected and actual are int or long types, since the delta is
meaningless for exact integer comparison.

* Inline JavaParser initializer instead of caching in field

* Update generated recipes.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

MigrateHamcrestToAssertJ handling of three arg assertEquals with numerical arguments

1 participant