mardi 23 février 2016

Method is not called with OCMClassMock

Hi there,

I am writing unit tests with OCMock and I am unable to understand why the following test fails. I am trying to test this method from a class called MyOtherViewController :

// private method of firstViewController
- (void)goToInitialViewController
{
    // type of secondViewController is SecondViewController
    [secondViewController showInitialViewController];
}

Here the test I wrote :

- (void)testShowInitialVCCalledWhenGoToInitialVCCalled
{
    id secondVCMock = OCMClassMock([SecondViewController class]);

    FirstViewController *firstVC = [FirstViewController new];

    [firstVC goToInitialViewController];

    OCMVerify([secondVCMock showInitialViewController]);
}

I also trying using OCMPartialMock([SecondViewController new]) but the test still fails. I thing I am missing something concerning mocks.

Any help would be appreciated ! Thanks

Aucun commentaire:

Enregistrer un commentaire