ocmock icon indicating copy to clipboard operation
ocmock copied to clipboard

Selectively Ignoring Object Arguments

Open alanterranova opened this issue 8 years ago • 2 comments

Hi Erik,

Now that OCMock retains arguments passed to mocks, I’m unable to test dealloc logic for objects whose references are retained by mocks.

Is it possible to enable "legacy" behavior on a per-mock basis, such as adding a method on OCMockObject that skips retention ("noRetainObjectArgs") or releases arguments ("releaseObjectArgs")? Happy to contribute if either seems reasonable.

Thanks,

Alan

alanterranova avatar Oct 12 '17 03:10 alanterranova

I understand the issue. However, this seems to be quite a niche use case and, at the same time, this would make some already complex logic inside OCMock even more complex and it would require changes to the API.

For your cases could you not just send a release to the objects in question from your test code? I know it feels "asymmetric" but it's also pragmatic.

erikdoe avatar Oct 14 '17 10:10 erikdoe

In some cases I can nil the mocks in question, but not mocks that need to be verified. Explicitly releasing the objects under test is disallowed in ARC. That's where having the ability to release (or simply not retain) arguments would be useful.

alanterranova avatar Oct 15 '17 06:10 alanterranova