lundi 22 décembre 2014

How to spy on a class method in Kiwi?

I've looked through various examples with class mocking, like these:


http://ift.tt/1Cujsa8


http://ift.tt/1CujtuK


Mocking expectations in Kiwi (iOS) for a delegate


The class Test has a class method fetch.


What I am trying to achieve is to see if a method from a class gets called during the work of the class I want to test.


What I do:



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
});


And the test fails with the following error:



[FAILED], expected subject to receive -fetch exactly 1 time, but received it 0 times


What am I doing wrong? How the spy mechanism should work on class methods?


Aucun commentaire:

Enregistrer un commentaire