Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to verify number of method calls using OCMock

Tags:

Is there a way to verify that a method has been called 'x' amount of times?

like image 450
qnoid Avatar asked Mar 25 '11 15:03

qnoid


1 Answers

Looking at the test file for OCMock, it seems that you need to have the same number of expects as you have calls. So if you call someMethod three times, you need to do...

[[mock expect] someMethod]; [[mock expect] someMethod]; [[mock expect] someMethod];  ...test code...  [mock verify]; 

This seems ugly though, maybe you can put them in a loop?

like image 190
GoatInTheMachine Avatar answered Jan 12 '23 20:01

GoatInTheMachine