-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
failNotSame
message could emphasize reference equality
#1626
Comments
There are cases when identityHashCode is not needed, like |
Well, technically Instead of targeting specific cases why not just address the essence of the issue - identical
Then even cases like
|
@sabi0 FWIW JUnit Jupiter includes the identity hash code if both strings are equal. https://github.com/junit-team/junit5/blob/b7897dbf9c70158f3fee76c56b9c1508b416968c/junit-jupiter-api/src/main/java/org/junit/jupiter/api/AssertionUtils.java#L115-L129 |
When calling
assertSame
for two different instances of identical objects the failure message will be quite confusing: "expected same:<[1, 2]> was not:<[1, 2]>".See
junit4/src/main/java/org/junit/Assert.java
Line 829 in 8c9e81d
I think the clarity could be improved by adding identityHashCode to the message, like this:
"expected same:<[1, 2]@ba38e> was not:<[1, 2]@de440>"
Or maybe even with the class name:
"expected same:<java.util.List@ba38e [1, 2]> was not:<java.util.List@de440 [1, 2]>"
The text was updated successfully, but these errors were encountered: