• 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
problem unit testing core data
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: problem unit testing core data
      • From: Matthew Firlik <email@hidden>
    • Re: problem unit testing core data
      • From: Tim Hart <email@hidden>
  • Prev by Date: Re: Dynamically changing title of 'Application Menu'
  • Next by Date: performSelectorOnMainThread
  • Previous by thread: Re: Dynamically changing title of 'Application Menu'
  • Next by thread: Re: problem unit testing core data
  • Index(es):
    • Date
    • Thread