-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Print the fully qualified class names if the simple class names are the same #2311
Comments
This is probably a relatively simple change. For anybody who is looking to contribute to Mockito, this is a good starter bug! |
I would love to try to fix this. |
@saurabh7248 Awesome. Looking forward to the PR! |
Sorry, I got some misunderstanding. I revert my PR. :) |
@chaehwanli Looking at https://github.com/chaehwanli/mockito/commit/2175bfb43e75d80976d75ab0338aaf751cdee9eb I think that would be the correct fix for this. Do you mind sending that as a PR? |
@TimvdLippe |
Prints fully qualified class name when the simple names of arguments match.
@chaehwanli's changes would have printed the full name even when the classes would have different simple names. |
@saurabh7248 Ah good catch. Thank you so much both of you to work on this and iterating on a solution 😄 That approach SGTM. I think there are some small improvements we can make in terms of code structure, but I like that approach as well. If you could open a PR, then we start discussing the implementation there and iterate on that separately from this issue thread. Thank you for your work thus far! |
Have opened a pull request here. |
Made changes to Equals.toStringWithType by reusing same method to achieve both cases by sending a boolean as an input, based on which either simple name or fully qualified name will be used for describing the type. Also in the method ArgumentMatchingTool.getNotMatchingArgsWithSameName return Set<String> which return the simple names of classes having more than one classes with different FQCN.
Fixed the style issues, by running gradlew :spotlessApply Also needed to handle the case where argument is null, which gave null pointer while getting class name from the object.
Fixed in 1ad8235 |
I have 2 overloads of a method:
setDeadline(java.time.Duration)
setDeadline(org.joda.time.Duration)
There's a mocking failure in a test (calling the wrong overload), but the error message isn't super helpful:
The output attempts to include the classnames to help disambiguate, but in this case, the simple class names are identical (
Duration
). We should be able to detect this, and print the FQCNs if the simple names are equal.Alternatively, we could always print the FQCNs:
mockito/src/main/java/org/mockito/internal/matchers/Equals.java
Line 55 in 6f9108b
(We already do something similar in Truth.)
The text was updated successfully, but these errors were encountered: