Using the hamcrest library for Java, what's a nicely readable way to do the opposite of:
assertThat(someCollection, hasItem(someItem))
I want to make sure someCollection
does not contain item someItem
The Not Contains assertion verifies that some specific value is missing from the message.
Class IsNot<T> Calculates the logical negation of a matcher. Generates a description of the object. Evaluates the matcher for argument item .
Negate the hasItem
assertion
assertThat(someCollection, not(hasItem(someItem)))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With