mercredi 1 avril 2015

How to get the number of times a mock is called in Mockito

I'm using PowerMockito with Mockito to mock a few static classes. I want to get the number of times a particular mock object is called during run time so that I can use that count in verify times for another mock object.


I need this because, the method I'm testing starts a thread and stops the thread after a second. My mocks are called several times in this 1 second. After the first mock is called, code branches and different mocks can be called. So, I want to compare the count of first mock with the count of other mocks.


This is a legacy code. So I cannot make changes to actual code. I can only change test code.


Aucun commentaire:

Enregistrer un commentaire