-
Notifications
You must be signed in to change notification settings - Fork 379
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 "normal" objects to describe themself, e.g. in case of a mismatch #244
base: master
Are you sure you want to change the base?
Conversation
What is the situation where you can't use the |
If I remember correctly, this only works for matchers, but not for POJOs, right? Roughly speaking, my problem occured when calling |
This change seems like an improvement. @PirolA, can you add a test for the changed functionality to this PR? |
@@ -29,6 +31,19 @@ public Description appendDescriptionOf(SelfDescribing value) { | |||
public Description appendValue(Object value) { | |||
if (value == null) { | |||
append("null"); | |||
} else if (value instanceof SelfDescribing){ |
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.
There is a fundamental problem with this approach: normally hamcrest would be a test dependency.
@PirolA interesting idea, as some previous comments have highlights it would mean hamcrest being a non compile dependency. maybe looking at how please can you rebase from master, as |
Going to try and kick start hamcrest, so if you want to get it merged, please rebase from the branch |
9bc653b
to
e9f7fc8
Compare
Motivation
I needed to give detailed descriptions of an object in case of a mismatch and couldn't use toString().
Solution
SelfDescribing
Interface and retrieve a description based on itsdescribeTo
method.