Skip to content
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

IsIterableContainingInAnyOrder should use describeMismatch for items #47

Open
dschulten opened this issue Mar 11, 2014 · 2 comments
Open

Comments

@dschulten
Copy link
Contributor

IsIterableContainingInAnyOrder tries to describe the mismatch like this in Matching.isMatched, thus relying on toString:

    mismatchDescription.appendText("Not matched: ").appendValue(item);

Rather it should use the same approach as IsIterableContainingInOrder and use the offending matcher to describe the mismatch. Here is what the IsIterableContainingInOrder Matcher does:

if (!matcher.matches(item)) {
    describeMismatch(matcher, item);
    return false;
}
@dschulten
Copy link
Contributor Author

see also:
http://code.google.com/p/hamcrest/issues/detail?id=108 about how TypeSafeDiagnosingMatcher overrides describeMismatch() and calls matchesSafely() again, this time passing in the mismatchDescription which was given to it by assertThat()

also related:
http://code.google.com/p/mockito/issues/detail?id=409

@josephw
Copy link
Contributor

josephw commented Feb 26, 2015

At that point, there may be more than one Matcher, and none of them matched. This isn't quite like IsIterableContainingInOrder where it's a specific matcher that failed.

This could pick an arbitrary matcher to ask for a description, or use describeMismatch only when there's a single matcher available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants