-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Allow custom matcher functions to return error strings displayed on a failed match #639
Allow custom matcher functions to return error strings displayed on a failed match #639
Conversation
@brandonbodnar-wk Yep, its hard to debug this, and we need better error message. Also it returns unexported We can log the errors needed in the |
Thanks @devdinu. This is a breaking change, but as far as I can tell, it will only break for someone that was reliant on the existing However, if the maintainers feel this break is too much, I can break the functionality into a separate function from @ernesto-jimenez evaluated altering the return value of |
Changes to the method signature for argumentMatcher.Matches may lead to breaking existing external uses of that function. Introducing a new method used internally allows presenting the error information out for internal testify functionality while not breaking other existing uses of Matches.
I've added an additional unexported method and moved the error producing logic into that method. I've also changed the existing Matches method to use the output of that new method, but without any changes to the existing method's signature. This should prevent this PR from introducing any breaking changes, which still allowing the new functionality. |
@brandonbodnar-wk do you still want to do this? Can you resolve merge conflicts? |
…from-custom-matcher
…from-custom-matcher
@georgelesica-wf Sorry for the delay. I've updated this PR with latest from master to address the merge conflict. |
Awesome, I've requested one more quick review and then I'll merge. |
+1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks!
Switched to another PR since there were merge conflicts and this fork is no longer accessible. See #781 |
Custom Matchers are super helpful, but the failure messages are less so. This PR allows those using MatchedBy to return a custom error response for a failed match to control the output on failure. Additionally, this cleans up the output for the closest call arguments.
For example, the current version of testify gives the following output for the following test
Test
Output
This PR now allows for
Test
Output