Testing class method using OCMock release 2.1.1

前端 未结 2 1554
鱼传尺愫
鱼传尺愫 2021-01-27 14:52

I am trying to check if a class method is getting invoked using OCMock. I have gathered from OCMock website and other answers on SO that the new OCMock release (2.1) adds suppor

2条回答
  •  清歌不尽
    2021-01-27 15:28

    Maybe I'm missing something here (and I know this is a bit old), but your class signature is +(BOOL)getBoolVal { return YES; } and in your test, you're calling expect on getBoolVal:nil

    Those don't match, right? In that case, your class mock will say, "Oh, that's not the signature I expect" and try to pass it on to the underyling class, I believe. See the forwardInvocationForClassObjectin the OCMock source.

    As far as why you're getting NO (since the underlying class also returns YES, which makes this test kind of moot, but that's another issue), I'm not 100% sure, but maybe it's just a C-ism -- 'indeterminate value, void, 0 (false/NO)"

提交回复
热议问题