title: OCUnit Test my app with UINavigationController and UITableView
body: <p>I want to write integration application test to test the full CRUD operations. I have a table view to list all objects. User can click "Add" button to push a new detail view controller to add a new object; They can click on an existing object to push a detail view controller to rename the object; They can also delete the object from the list.</p>
  
  <p>I got excited to try out OCUnit to test my app.  However, I have ran into some weird bugs.  I am using UITabBarController + UINavigationController.  I have more than 3 levels of pushViewController in my UINavigationController.  If I test the code as it is with [self.navigationController pushViewController:viewController animated:YES] , it mostly works with two warnings:</p>
  
  <pre><code>nested push animation can result in corrupted navigation bar
  nested pop animation can result in corrupted navigation bar
  </code></pre>
  
  <p>I noticed viewDidAppear isn't called hence the warnings.</p>
  
  <p>Then I try to workaround by changing animated:YES to animated:NO.  The warnings go away.  However, I ran into another bug where viewDidLoad isn't called at all.  So the view doesn't load from the NIB file and all the IB controls are nil.  This wasn't the case if I set animated to YES.</p>
  
  <p>This is the code I use to get a handle of the root view controller in the UINavigationController.</p>
  
  <pre><code>app = (MyAppDelegate*) [[UIApplication sharedApplication] delegate]; 
  rootVC = ((MyViewController*)[[((UINavigationController*)[app.tabBarController.viewControllers objectAtIndex:0]) viewControllers] objectAtIndex:0]);
  </code></pre>
  
  <p>I manually called this code in my test to simulate a click on the UITableView:</p>
  
  <pre><code>[rootVC tableView:rootVC.tableView didSelectRowAtIndexPath:ip];  // push is called inside this
  </code></pre>
  
  <p>So I am stuck either I set animated:YES or animated:NO.  Does anyone successfully use OCUnit to test apps with UINavigationController + UITableView?  If so, could you please share some sample code or your experience?</p>