vendredi 24 mars 2017

Java mockito service test parameter negation

I try to test my service with mockito 2.7.15.

First I try this:

when(customerDaoMock.find(AdditionalMatchers.not(id1))).thenReturn(null);

But I got a InvalidUseOfmatchersException.. So I googled the problem and found this stackoverflow question. After that my second try would have been:

when(customerDaoMock.find(AdditionalMatchers.not(Mockito.argThat‌(id1)))).thenReturn(null);

but Mockito class has no longer method argThat

So my question is how can I use not negation method in mockito?

Or is there any other option, or better solution for this problem?

Aucun commentaire:

Enregistrer un commentaire