Open GoogleCodeExporter opened 8 years ago
The problem is that the description
a string ending with "bar"
is produced by endsWith(), and not() doesn't parse English so it merely
prefixes it with
not
to produce the awkward phrase you see. Each Matcher would need to be aware of
negation to produce better messages. One solution would be to create a
Negatable interface (yes, find a better name) that has one method:
describeNegativeMismatch()
The name comes from the PHP version of Hamcrest, so maybe Java's is different.
It would produce a similar message but with "not" embedded within it.
Not.describeMismatch() would check if the matcher it is negating implements
that interface and call the above method if it does. If not, it would prefix
"not" as it does now.
This would allow the majority of matchers that work fine as-is to continue on
while providing a simple method to generate nice-reading failure messages.
Original comment by dharkn...@gmail.com
on 5 Jul 2010 at 6:02
Original comment by dharkn...@gmail.com
on 26 Jul 2010 at 9:49
tagged
Original comment by t.denley
on 12 May 2012 at 10:48
Original issue reported on code.google.com by
schm4...@gmail.com
on 27 May 2010 at 6:54