lundi 5 janvier 2015

Java verify void method calls n times with Mockito

I'm trying to verify that a (void) method is being called inside of a DAO - I'm using a commit point that sends a list of results up to that point, resets the list and continues. Say I have 4 things in the list and I have a commit point of 1, I would expect the "send" method to be called 4 times. I can verify that the method gets called once by writing


Mockito.verify(mock).send()


it passes.. but I want to verify the number of times it was called. I would think that


Mockito.verify(mock.send(), times(4))


would be sufficient, but it says the parameters are not correct for verify.


Incidentally, if I change Mockito.verify(mock).send() to Mockito.verify(mock.send()) or Mockito.verify((mock).send()) I get the same error. Thoughts on this?


Aucun commentaire:

Enregistrer un commentaire