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 8395973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:25:39+00:00 2026-06-09T20:25:39+00:00

When I test my app using OCUnit, it sets up the AppDelegate, window and

  • 0

When I test my app using OCUnit, it sets up the AppDelegate, window and rootViewController as usual before running the tests. My rootViewController then adds itself as an observer for some NSNotifications.

When I test these notifications with isolated test instances and mock observers, the notification handler of the automatically created rootViewController is called as well, which causes some of my tests to fail.

Is there a way to keep OCUnit from creating the rootViewController or make it use a different ViewController class when running in test mode? It would be cool if this could be done without writing special test-related code in my app code.

  • 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-06-09T20:25:40+00:00Added an answer on June 9, 2026 at 8:25 pm

    Update: What I do today is slightly different from the answer below. See How to Easily Switch Your App Delegate for Testing

    It does require adding a little bit of test-specific code to your app code.
    Here’s what I do to avoid my full startup sequence:

    Edit the scheme

    • Select the Test action
    • In “Test” select the Arguments tab
    • Disable “Use the Run action’s options”
    • Add an environment variable, setting runningTests to YES

    Edit your app delegate

    • Add the following to -application:didFinishLaunchingWithOptions: as soon as it makes sense to:

      #if DEBUG
          if (getenv("runningTests"))
              return YES;
      #endif
      
    • Do the same for -applicationDidBecomeActive: but simply return.

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

Sidebar

Related Questions

My WPF test app (very simple, just one window) is using a 3rd party
I've just started writing tests for my iOS app, I'm using Xcode4 and OCUnit.
I set up a test app using ActionbarSherlock 4.0, which works fine in the
So I am making a test app using RequireJs, Mustache and Backbone.js. I had
I am trying to test a sinatra app using minitest and capybara but get
I'm trying to test in-app billing using my own sku/product ID upgrade_to_premium. As I
I have Ripple which im using to test app made for android. App is
I wrote a feature to test the default configuration of my web app using
I'm using the Android emulator to test my app. I made an AVD with
I'm trying to test using QTP a web app that is using ajax4jsf to

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.