erikdoe / ocmock

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

Prevent initialization in production code from resetting mock state. #351

Closed alanterranova closed 6 years ago

alanterranova commented 6 years ago

A common pattern in our tests is to create a mock that returns itself from alloc/init in production code. The problem is that the mock object implements init which can't be stubbed, so calling init from production code resets state including stubs and expectations. The fix is to simply prevent resetting mock state when init is called multiple times.