How to assert that a list does not contain something, with FEST?
fest, java, testing
Solution
I've just been having a browse through the source code for the version 1 branch and found this:
/**
* Verifies that the actual group of objects does not contain the given objects.
*
* @param objects the objects that the group of objects should exclude.
* @return this assertion object.
* @throws AssertionError if the actual group of objects is {@code null}.
* @throws NullPointerException if the given array is {@code null}.
* @throws AssertionError if the actual group of objects contains any of the given objects.
*/
public final @Nonnull S excludes(@Nonnull Object... objects) {
assertExcludes(objects);
return myself();
}
I probably shouldn't make wild assumptions like this, but it's in the same class as your `contains` method (`ObjectGroupAssert`) and the Javadoc seems to describe the functionality you're looking for.
So I think, you would just need:
assertThat(list).excludes(5,7);
Problem
I'm using FEST to write assertions in JUnit. It's easy to assert that a list is containing some elements: ``` assertThat(list).contains(2,4); ``` But how to assert that the list is not containing something? Like: ``` assertThat(list).doesnotContain(3); // !!! no such method ```