I am trying to verify that a ListView
does not contain a particular item. Here's the code I'm using:
onData(allOf(is(instanceOf(Contact.class)), is(withContactItemName(is("TestName")))))
.check(doesNotExist());
When the name exists, I correctly get an error because of check(doesNotExist())
. When the name does not exist, I get the following error, because allOf(...)
doesn't match anything:
Caused by: java.lang.RuntimeException: No data found matching:
(is an instance of layer.sdk.contacts.Contact and is with contact item name:
is "TestName")
How can I get functionality like onData(...).check(doesNotExist())
?
EDIT:
I have a terrible hack to get the functionality I'd like by using try/catch and inspecting the event's getCause(). I would love to replace this with a good technique.