problem unit testing core data
problem unit testing core data
- Subject: problem unit testing core data
- From: Jesse Grosjean <email@hidden>
- Date: Wed, 26 Oct 2005 10:51:34 -0400
I'm seeing the following error when I run unit tests on my
NSPersistentDocument based application:
2005-10-26 08:53:18.068 otest[19257] *** -[NSAutoreleasePool
dealloc]: Exception ignored while releasing an object in an
autorelease pool: The NSManagedObject with ID:0x346e060 <x-coredata://
FD637DAE-68F9-4B0B-BC4F-7646659C9C4A/ContentIndex/p114> has been
invalidated.
The error occurs after running each test case as the auto-release
pool for that test case is released, then the otest tool crashes
after running all of the tests. Here's some more notes on what's
going on, please let me know if you have ideas on where I'm going
wrong or thoughts on getting around the problem. Here's my setUp and
tearDown methods:
- (void)setUp {
NSString *path = [NSTemporaryDirectory()
stringByAppendingPathComponent:@"test.mydocument"];
[[NSFileManager defaultManager] removeFileAtPath:path handler:nil];
// openNewDocumentAndSaveAs: is a category method that calls
makeUntitledDocumentOfType, adds to document to the document
controller and saves
// the new document at the given location.
document = [[[NSDocumentController sharedDocumentController]
openNewDocumentAndSaveAs:[NSURL fileURLWithPath:path] display:NO
error:nil] retain];
}
- (void)tearDown {
[document close];
[[NSFileManager defaultManager] removeFileAtPath:[[[document
fileURL] path] stringByDeletingLastPathComponent] handler:nil];
[document release];
}
The exception is thrown as the managed object context is being
dealloced (maybe somewhere in the private _dispose: method). It's
important to note that when I run my application normally I see no
errors when opening and closing documents and ObjectAlloc shows that
objects are being created and released as expected.
Does anyone know what might be the problem and how best to fix it?
Thanks,
Jesse
_______________________________________________
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