assert.Same: add type names to fail message #1056
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a type names of testing values to a fail message of
assert.Same().Changes
Adds type names of testing values to a fail message of
assert.Same(), which might be necessary to identify the cause of failing.Motivation
Currently, when
assert.Same()fails, it outputs a message with pointer values and its go-syntax representation ofactual/expectedvalues.assert.Same()would fail when types of two values are different. The following test code would fail:However, it seems no difference between
actualandexpectedin its fail message, because they point to the same object. It would be hard to know why the test fails from this message.This PR adds type names of two values. The output would be like this:
Related issues