erikdoe / ocmock

Mock objects for Objective-C
http://ocmock.org
Apache License 2.0
2.16k stars 606 forks source link

Avoid a macros misuse #367

Closed Regno closed 4 years ago

Regno commented 5 years ago

Description of Changes

Exception raises when OCMStub/OCMReject/OCMExpect used only to mocked object, so we added a flag isEverInvoked to check if the mock exists instead the using a real object. If YES - the needed chain of the mocking process raises, if NO - exception “OCMStub/OCMReject/OCMExpect must be used only to mocked object.” Raises to make you understand what goes wrong.

Motivation and Context

When you uses OCMStub/OCMReject/OCMExpect on a real object in a test - your test doesn’t check anything and is always green. You must use mocks in the test (class / partial). In this case, the correct code check is performed.

How Has This Been Tested?

Local and CI successful builds and xctests over the new code.

Notes

OCMStub/OCMReject/OCMExpect must be used only to mocked object.

Co-Authored-By: QB victoriaqb@users.noreply.github.com