-
Notifications
You must be signed in to change notification settings - Fork 376
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
TypeSafeDiagnosingMatcher/CombinableMatcher conflicts with nullValue Matcher #49
Comments
Today I also was puzzled why |
Proposed a solution here: #56 |
If that's the behaviour you want, then you probably want a different matcher. The point of a TypeSafe matcher is that confirms that the actual value has the right type, which null doesn't. I'm also wondering about the use case for "either something or null" in an assertion. Surely you know which one is appropriate when you write the test? |
Maybe the fact that one wants to use One idea might be to add a mismatch description to |
It's up to the assertion calling the matcher to report the actual value. In this case, I would expect it to show the |
This is caused by this little pice of code in TypeSafeDiagnosingMatcher
The This can be fixed by adding this dirty hack to CombinableMatcher
Therefore TypeSafeDiagnosingMatcher's matches method must be non final and ShortcutCombination needs a getter for matchers. I know this is really dirty, maybe someone can make a fix with this information. I'll also try to write a better fix for that. EDIT:
|
The following assertion never evaluate to true:
The root cause lies in the CombinableMatcher being a TypeSafeDiagnosingMatcher which implements
matches()
as:Thus for
null
the matchers will never be queried. I suppose the solution should be something like:The text was updated successfully, but these errors were encountered: