Regarding Expect and stub

Discussion of the OCMock framework. If you have patches we would prefer you to send them to the mailing list, but attaching them to a topic is possible, too.

Regarding Expect and stub

Postby amit » 27 May 2014, 19:28

Hi,

Could you please explain me difference between expect and stub in ocmock using objective c.
I am too much confuse there is no proper explanation on that.

Someone answer this as -:

The basic difference is this: you expect things that must happen, and stub things that might happen.

There are 2 ways mock objects fail: either an unexpected/unstubbed method is called, or an expected method is not called.

Unexpected invocations. When a mock object receives a message that hasn't been either stubbed or expected, it throws an exception immediately and your test fails.
Expected invocations. When you call verify on your mock (generally at the end of your test), it checks to make sure all of the methods you expected were actually called. If any were not, your test will fail.



Please help on this topic.
amit
 

Return to OCMock