What is the difference between OCMock's wait methods and stubs?

I am trying to use OCMock to test my application. But I'm confused, where should we use the wait and where to use the stub? Can anyone help?

+6
source share
1 answer

The main difference is this: you expect things that should , and stub events can .

There are two ways to make false errors: either an unexpected / unsolved method is called, or the expected method is not called.

  • Unexpected calls. When a dummy object receives a message that was neither wired nor expected, it immediately throws an exception and your test fails.
  • Expected Challenges. When you call verify on your layout (usually at the end of your test), it checks to see if all the methods that you expected were actually called. If there were none, your test will fail.

There are several types of bullying that change this behavior: beautiful bullying and partial bullying. Pleasant bullying does not allow you to stifle methods - basically they allow you to make unexpected calls. Partial bullying is a way to intercept messages sent to real objects. Any messages that you expect or overlay on a partial layout will be sent to the layout. All other messages are sent to the actual object. For both pleasant mocks and partial mocks, you will not get a test error for unexpected calls (rule No. 1 above).

+13
source

Source: https://habr.com/ru/post/918442/


All Articles