I'm new to OCMock and i'm trying to test if a method is called, except I want the method to be a stub since it contains other loading methods I do not care to test in the current test.
- (void)setUp
{
self.rootViewController = [[RootViewController alloc] init];
}
- (void)tearDown
{
self.rootViewController = nil;
}
- (void)test_ViewDidLoad_DidCallLoadChildViewControllers
{
id mockRootViewController = [OCMockObject partialMockForObject:self.rootViewController];
[(RootViewController*)[mockRootViewController stub] loadChildViewControllers];
[(RootViewController*)[mockRootViewController stub] updateMainNavigation];
[[mockRootViewController expect] loadChildViewControllers];
// Force the view to load
self.rootViewController.view;
[mockRootViewController verify];
}
And here is the method that is getting called:
- (void)viewDidLoad
{
[super viewDidLoad];
[self loadChildViewControllers];
[self updateMainNavigation];
}
For some reason the test is failing as if it is never called (yet I can step thru it and verify that it is getting called, as well as it being a stub.
Here is the error:
OCPartialMockObject[RootViewController]: expected method was not invoked: loadChildViewControllers
What am I missing?