Unit Testing Core Data - exited abnormally with code 134?

Put a @try .... catch block around your testcase I think loading the model with NSManagedObjectModel mergedModelFromBundles: nil did not work as expected Using your code for initialization of the core data stack I got an exception entityForName: could not locate an entity named 'Unit' in this model Changing the model initialization to the following code works fine: set according to the identifier in your modeltest Info. Plist NSString* path = NSBundle bundleWithIdentifier:@"com.yourcompany. ModelTest" pathForResource:@"CoreDataUnitTest_DataModel" ofType:@"mom"; NSURL* modelURL = NSURL URLWithString:path; managedObjectModel = NSManagedObjectModel alloc initWithContentsOfURL:modelURL Unit Tests with OCUnit sometimes are a bit tricky as only little information on errors is exposed.

Put a @try .... catch block around your testcase. I think loading the model with NSManagedObjectModel mergedModelFromBundles: nil did not work as expected Using your code for initialization of the core data stack I got an exception +entityForName: could not locate an entity named 'Unit' in this model. Changing the model initialization to the following code works fine: // set according to the identifier in your modeltest Info.

Plist NSString* path = NSBundle bundleWithIdentifier:@"com.yourcompany. ModelTest" pathForResource:@"CoreDataUnitTest_DataModel" ofType:@"mom"; NSURL* modelURL = NSURL URLWithString:path; managedObjectModel = NSManagedObjectModel alloc initWithContentsOfURL:modelURL; Unit Tests with OCUnit sometimes are a bit tricky as only little information on errors is exposed.

Thanks Martin, I think you're right. I still can't quite get it to find the correct path though. I added a line: STAssertNotNil(path, @"The path to the resource cannot be nil."); after your suggested code, and it's erroring there.

I've checked that NSBundle bundleWithIdentifier:@"com.testcompany. AppLogicTests" is not nil, so that only leaves the name for the resource for me to have messed up. What's the magical resource name (or how do I find it) that will get things running?

Thanks. – Neal L Jul 14 '10 at 14:06 pathForResource: "$name" is the name of your datamodel file. You also have to add the datamodel to the unit test target "$name.

Xdatamodel" within your project (.xcdatamodeld for versioned data models) ofType: @"mom" or @"momd" Probably take a look at my project with unit tests at github. Com/mbrugger/CoreDataDependentProperties/tree/master/… – Martin Brugger Jul 14 '10 at 15:17 Adding to "put a @try .... catch block around your testcase" above: the exception is probably being written to Console, so have a look in there for the unhandled exception. – Martin Dow Jul 15 '10 at 22:14.

I got the same problem today, and I think Martin Brugger is right, but there is also an alternative method for getting bundle resrouce, if you could not get resource. You can try get the bundle by NSBundle bundleForClass:self class here is my code to make the core data unit test work NSBundle * bundle = NSBundle bundleForClass:self class; managedObjectModel_ = NSManagedObjectModel mergedModelFromBundles:NSArray arrayWithObject:bundle; NOTE: pls also ensure . Xcdatamodel is included in your unit test target.

Not sure quite how long I spent trying to figure this out. Too long. Thanks!

– Clivest Jul 14 at 18:29.

I am setting up unit testing for my core data app. I'm running into a strange problem in a pretty simple test. If I omit the - (void)testNewUnitDefaults test, then the build completes without errors, so something in that last test is throwing it for a loop.

I am new to this, so any assistance would be greatly appreciated!

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions