jonreid / OCMockito

Mockito for Objective-C: creation, verification and stubbing of mock objects
MIT License
991 stars 118 forks source link

Expected nil, but was nil #139

Closed pikaboo closed 7 years ago

pikaboo commented 7 years ago

How does this even happen?

Here is code to reproduce:

        _scriptManager = OCMPartialMock([ScriptsManager manager]);

        OCMStub([_scriptManager cachedData]).andReturn(nilValue());
        id expected = nilValue();
        id actual = [_scriptManager cachedData];
        assertThat(actual, equalTo(expected));

code from the library:

- (BOOL)matches:(id)item
{
    if (item == nil)
        return self.expectedValue == nil;
    return [item isEqual:self.expectedValue];
}

item == nil returns false

please see stackoverflow post below.

http://stackoverflow.com/a/5914886/2136812

jonreid commented 7 years ago

What is the question? Is there an OCMockito issue?

pikaboo commented 7 years ago

The question is: why is nil != nil ?

jonreid commented 7 years ago

Your example shows OCMock, not OCMockito. Do you have an OCMockito question?