Search code examples
iosobjective-cxcodetestingxcode4

ECSlidingViewController and testing


I'm using ECSlidingViewController 0.9.0 (https://github.com/edgecase/ECSlidingViewController). I started with a fresh install with core data, arc & testing enabled, and installed ECSlidingViewController with Cocoapods.

When I run it in test mode, for some reason the slidingViewController method returns null instead of the InitialSlidingViewController.

This is the method defined in ECSlidingViewController.m

- (ECSlidingViewController *)slidingViewController
{
  UIViewController *viewController = self.parentViewController;
  while (!(viewController == nil || [viewController isKindOfClass:[ECSlidingViewController class]])) {
    viewController = viewController.parentViewController;
  }

  return (ECSlidingViewController *)viewController;
}

In both simulator and test, self.parentViewController returns an InitialSlidingViewController.

But in test mode, [viewController isKindOfClass:[ECSlidingViewController class]] returns false instead of true.

Any idea where I should look next


Solution

  • Problem wasn't related to ECSlidingViewController.

    The answer is here isKindOfClass: returns false negative in unit test bundle.

    I removed the app's source files in the test bundle's compile sources build phase and it works now.