Re: OCUnit unit tests and user defaults...
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