Skip to content

Create Iterable/Collection matcher like: doesNotContainAnyOf(T [] items) #195

Open
@Vitalik549

Description

@Vitalik549

Case:

List<String> list = Arrays.asList("a", "b", "c");
String[] cd = {"c", "d"};

assertThat("Should not contain each item", list, not(hasItems(cd)));

This assertion won't fail. I understand why it will pass, though it's not expected by most of users.

It would be nice to have simple Matcher to check that "every item is not in the list"

# Now it's possible to use:
assertThat("Should not contain each item", list, everyItem(not(isIn(cd))));

# But that looks much better:
assertThat("Should not contain each item", list,  doesNotContainAnyOf(cd));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions