0
我已經通過與一流的嘲諷各種實例看,像這樣的:如何窺視獼猴桃的類方法?
https://groups.google.com/forum/#!topic/kiwi-bdd/hrR2Om3Hv3I
https://gist.github.com/sgleadow/4029858
Mocking expectations in Kiwi (iOS) for a delegate
類Test
有一個類的方法fetch
。
我想要實現的目的是在類的工作過程中調用我想要測試的方法。
我做什麼:
it(@"test", ^{
id mock = [KWMock mockForClass:[Test class]];
[[mock should] receive:@selector(fetch)];
Repository *rep = [[Repository sharedInstance] rep]; //method `rep` invokes [Test fetch] at some point
});
並導致測試失敗,出現以下錯誤:
[FAILED], expected subject to receive -fetch exactly 1 time, but received it 0 times
我在做什麼錯?間諜機制應如何處理類方法?