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

added ContainsAllMatcher #15

Closed
wants to merge 1 commit into from
Closed

Conversation

dkandalov
Copy link

I called the matcher containsAllbut there are couple problems with this name:

I also have doubts that current mismatch description is good. Also passing custom "equality" matcher and nested iterables API looks a bit clunky.

@npryce
Copy link
Owner

npryce commented Oct 19, 2016

Hmmm... I think a matcher called containsAll should test the same thing as Collection.containsAll. What's the difference?

In fact, is assertThat(actual, Collection::containsAll, expected) good enough for your uses?

@dkandalov
Copy link
Author

dkandalov commented Oct 19, 2016

I agree about the name. It probably should be called something like equalToIgnoringOrder.
The difference is cases like this assertThat(listOf(1, 2, 3), !equalToIgnoringOrder(listOf(1, 2)))
but assertThat(listOf(1, 2, 3), Collection::containsAll, listOf(1, 2)).

@robfletcher
Copy link

Java Hamcrest has a matcher called containsInAnyOrder. It would make sense to name this one consistently.

@mcbeelen
Copy link

@npryce :
I hope this feature will be added.
I really like the syntax
assertThat(someCollection, containsAllInAnyOrder(someElement, anotherElement)

Avoiding the 'weird method references' in the test syntax keeps them readable.

@jensim
Copy link

jensim commented Sep 6, 2018

I agree with @robfletcher.
I too want this function badly, because i cannot use hamcrest for containsInAnyOrder in Kotlin due to generics missmatch.

@npryce npryce closed this Sep 18, 2020
@corbym
Copy link

corbym commented Nov 11, 2020

Please re-open this issue - containsAll is not the same as containsInAnyOrder.

Thanks

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

Successfully merging this pull request may close these issues.

None yet

6 participants