Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6544537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:28:39+00:00 2026-05-25T11:28:39+00:00

I want to write integration application test to test the full CRUD operations. I

  • 0

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.

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:

nested push animation can result in corrupted navigation bar
nested pop animation can result in corrupted navigation bar

I noticed viewDidAppear isn’t called hence the warnings.

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.

This is the code I use to get a handle of the root view controller in the UINavigationController.

app = (MyAppDelegate*) [[UIApplication sharedApplication] delegate]; 
rootVC = ((MyViewController*)[[((UINavigationController*)[app.tabBarController.viewControllers objectAtIndex:0]) viewControllers] objectAtIndex:0]);

I manually called this code in my test to simulate a click on the UITableView:

[rootVC tableView:rootVC.tableView didSelectRowAtIndexPath:ip];  // push is called inside this

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T11:28:40+00:00Added an answer on May 25, 2026 at 11:28 am

    First off, for unit tests, don’t get your root view controller from your app delegate. The actual root view controller is a singleton, and singletons in unit tests create inter-test dependencies. Instead, have the test set up (and tear down) its own view controller instance.

    Certain kinds of tests require the view controller to load its nib — for example, to create the table view. For these tests, call

    [rootVC view];
    

    To test that a view controller is pushed, use a testing subclass of your actual view controller and override navigationController to return a mock object you can verify. For example,

    @interface TestingMyViewController : MyViewController
    @property(nonatomic, assign) UINavigationController *mockNavigationController;
    @end
    
    @implementation TestingMyViewController
    
    @synthesize mockNavigationController;
    
    - (UINavigationController *)navigationController
    {
        return mockNavigationController;
    }
    
    @end
    

    Then have your test create a TestingMyViewController and a mock. Set up the mock, and assign it to the testing subclass. Invoke the method you want to test, then verify that the mock navigation controller received the call you expected, with the argument you expected.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to write a Swing application in Griffon but I am not sure
I want to write a little DBQuery function in perl so I can have
I want to write a command that specifies the word under the cursor in
I want to write a function in Python that returns different fixed values based
I want to write a function that takes an array of letters as an
I want to write a word addin that does some computations and updates some
I want to write some JavaScript that will change the onmousedown of a div
I want to write a real-time analysis tool for wireless traffic. Does anyone know
I want to write a raw byte/byte stream to a position in a file.
I want to write something that acts just like confirm() in javascript, but I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.