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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T22:08:29+00:00 2026-05-19T22:08:29+00:00

I am writing unit tests in GHUnit test framework. I have a NSMutableDictionary detailsDict

  • 0

I am writing unit tests in GHUnit test framework. I have a NSMutableDictionary detailsDict defined in my Application delegate.

In my application delegate I set some values in & save it.
It works fine in the app but when I try to call a method to set values on it in unit tests I am not able to set any value & dictionary remains empty.

In the test case I alloc init my appDelegate. Message a method from this object which sets a few keys but When I check for its values it remains empty.

Is there anything I dont know about unit testing or what am I missing….?

Any answers pointers will be highly appreciated.

EDIT: I got it I had to separately alloc init the detailsDic variable
like this

#ifdef UNIT_TESTING
    detailsDict = [[NSMutableDictionary alloc] init];
#endif

Still open to other answers on other ways of doing this.

  • 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-19T22:08:30+00:00Added an answer on May 19, 2026 at 10:08 pm

    You can’t alloc and init a variable. You can alloc and init an object, and indeed you do need to alloc and init this NSMutableDictionary object somewhere.

    The proper place to do that is somewhere that will run both for your application and for every test case. The app delegate’s init method is probably a good choice.

    That said, I’d say that your app delegate should not exist at all in your unit tests, because your unit tests are not an application. You should split out whatever functionality you mean to test into one or more separate controllers, which you create and work with from the app delegate and from the relevant unit tests.

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

Sidebar

Related Questions

I'm writing some unit tests and I have a lot of functions of the
I've been building a framework and writing unit tests in GHUnit. One of my
We are writing unit tests for our ASP.NET application that run against a test
I am writing unit tests for some of my code and have run into
I am writing unit tests in visual studio 2010. For test some functionality, I
Just embarking on using a test framework for writing unit tests and also the
I'm writing unit tests using Boost.Test against some old C math library. One of
I decided to start writing unit tests in our application. It uses Entity Framework
I have got to know that src/test/java is used for writing unit tests. I
I am writing unit tests to test an MVC application. How can I validate

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.