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

In Jmockit to Mockito recipe, times=0 should be replaced with never() and times(1) should not occur #561

Open
shivanisky opened this issue Aug 7, 2024 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers mockito

Comments

@shivanisky
Copy link
Collaborator

shivanisky commented Aug 7, 2024

What problem are you trying to solve?

In Jmockit to Mockito recipe, when migrating JMockit Expectation, if times=0 then it is migrated to verify(obj, times(0)).method() but Mockito.never() is more appropriate ie verify (obj, never()).method()

For Expectations with times=1 this should be migrated to a basic Mockito when with no times information, as that is the default when statement. Instead it is migrated to verify(obj, times(1)).method(); but should be verify(obj).method();

This may be quite easy to implement.

@shivanisky shivanisky added the enhancement New feature or request label Aug 7, 2024
@timtebeek timtebeek moved this to Backlog in OpenRewrite Aug 7, 2024
@timtebeek
Copy link
Contributor

Good improvements, thanks! Could even be separate recipes that are run after a migration, as they are just better patterns to use with Mockito, if we can make that work despite Mockito's troublesome type attribution at times. Could fold those into a Mockito best practices recipe to then improve the quality of Mockito usage independent of a migration, and is hopefully easier to manage going forward.

@shivanisky shivanisky added the good first issue Good for newcomers label Nov 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers mockito
Projects
Status: Backlog
Development

No branches or pull requests

2 participants