-
Notifications
You must be signed in to change notification settings - Fork 75
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
JMockit to Mockito - rewrite expectation results with the correct type #508
Comments
|
Thanks for branching off this item for more detailed discussion. I'll tag @tinder-dthomson since he likely has more in depth knowledge to share on what's the best approach here, given his previous involvement with this recipe. |
I did consider handling this in the recipe, but it also felt like an edge case since I encountered it quite infrequently. Using the wrong type as a return value for a stub feels like a bad practice in general. That being said, it is indeed a feature of JMockit, so supporting it in You will need to make your changes in |
@kernanj just checking if you're planning to implement this one? I might take a stab at it one of these days if I catch inspiration. |
@tinder-dthomson I spent some time digging a little deeper into the code to try and understand what the change might look like but haven't implemented anything yet other than writing some failing test cases so be my guest if you want to work on providing a solution 🙂 |
What problem are you trying to solve?
Within an Expectations block in JMockit, we can record method invocations and the expected result. JMockit has some internal logic to handle cases where there is a type mismatch between the result and the return type of the method and performs auto conversion.
Raising this ticket to kick off a discussion about creating a standalone recipe to clean this up or to add to the existing recipe created here - #415
See https://javadoc.io/static/org.jmockit/jmockit/1.49/mockit/Expectations.html#result for more info
Example
Consider the following class below:
A test mocking the methods above might look something like follows:
Running the existing JMockitExpectationsToMockito recipe
As you can see above, the existing recipe to rewrite expectations doesn't account for this type conversion. Should we look at creating a separate recipe to first look at fixing up these issues and then apply the JMockitExpectationsToMockito recipe?
Are you interested in contributing this recipe to OpenRewrite?
Yes
The text was updated successfully, but these errors were encountered: