• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: OCUnit unit tests and user defaults...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: OCUnit unit tests and user defaults...


  • Subject: Re: OCUnit unit tests and user defaults...
  • From: Daniel Jalkut <email@hidden>
  • Date: Sun, 8 Jan 2006 12:44:28 -0500

Hi Jiva - I was curious so I added some similar tests to my test suite, and at first observed exactly the same problem.

So I started adding debugging NSLogs for things like "what is the main bundle's identifier", etc. At some point it started working! So I removed all the extraneous tests one by one and it still worked.

Shrug - now it's working and I can't get it to break again. Sounds like an interesting bug!

As a workaround I wonder if you might experiment with asking for the persistent domain explicitly by name? I think it was perhaps even at this point that my code "started working" never again to fail...

Daniel

On Jan 8, 2006, at 11:37 AM, Jiva DeVoe wrote:

This code:

-(void)setUp;
{
NSMutableDictionary *defaultValues = [NSMutableDictionary dictionary];


    [defaultValues setObject:@"blah" forKey:@"FOO"];

[[NSUserDefaults standardUserDefaults] registerDefaults:defaultValues];
NSLog(@"blahblah");
}


-(void)testSomething
{
shouldBeEqual([[NSUserDefaults standardUserDefaults] stringForKey:@"FOO"], @"FOO");
}



Yields:

2006-01-08 11:33:20.912 TestApp[13942] blahblah
/Volumes/Home/Users/jiva/Projects/TestApp/UserDefaultsTest.mm:25: - [UserDefaultsTest testSomething] : '(null)' should be equal to 'FOO'



Does the same if I put it in +initialize and various other places... what's the deal? Can I not use userdefaults as I normally would when using unit tests?


Can someone shed some light on why this doesn't work?

I'm thinking it's because OCUnit does weird things with it's otest tool etc... if so... is there some way I can force it to work without hacking up my non-test code?

--
Jiva DeVoe
http://www.devoesquared.com
PowerCard - Intuitive Project Management for Mac OS X

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
sweater.com


This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >OCUnit unit tests and user defaults... (From: Jiva DeVoe <email@hidden>)

  • Prev by Date: Re: Newbie cuestion on document based app and menus
  • Next by Date: Why won't compile
  • Previous by thread: OCUnit unit tests and user defaults...
  • Next by thread: Why won't compile
  • Index(es):
    • Date
    • Thread