0

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

https://groups.google.com/forum/#!topic/kiwi-bdd/hrR2Om3Hv3I

https://gist.github.com/sgleadow/4029858

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?

Community
  • 1
  • 1
Dumoko
  • 2,614
  • 3
  • 25
  • 34

1 Answers1

1
[[Test should] receive:@selector(fetch)];

Thats how you should check it since its a method class not an instance class you dont need a mocked class object. The autocompletion when you write might not show it so you have to force this.

MRebisz
  • 71
  • 3