-
Notifications
You must be signed in to change notification settings - Fork 377
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
Naming of method Matchers#contains is ambiguous #140
Comments
What if To me this is intuitive to what the matchers are saying: if I didn't say anything about order, don't worry about it. |
Agree with your points, but this would be quite a breaking change. I'll look at deprecating. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In code reviews here, people often misread this:
As meaning this: "Assert that the collection contains 'x'".
But what it actually means is this: "Assert that the collection contains only 'x'".
This causes a lot of unnecessary questions to be raised on our code reviews where code was updated to use Hamcrest, just because it reads differently to what it's actually doing.
At the same time, people looking to write new code with Hamcrest are using autocompletion to find appropriate-looking methods, and will often try to use
contains
before discovering that they really wantedhasItem
.I would suggest
containsOnly
as a new name, butcontainsInAnyOrder
sort of has the same issue and I am finding it hard to jam the additional word in there.The text was updated successfully, but these errors were encountered: