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.
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