1

I am having trouble getting any test case to run after installing RestKit in my project (They were all working previously).

Here's the error I'm getting:

*** Assertion failure in +[RKEntityMapping mappingForEntityForName:inManagedObjectStore:]

Here's where it's happening:

RKEntityMapping *responseMapping = [RKEntityMapping mappingForEntityForName:@"DBSensor" inManagedObjectStore:objectManager.managedObjectStore];

My RestkitSetup methods are all being called (and working properly in the non-test build target), and I'm including CoreData.h, RestKit.h, and RestKit/Testing.h in the proper order. Is there something else I have to do to ensure that the ManagedObjectStore gets created properly?

Whoa
  • 1,334
  • 11
  • 26
  • Is the object manager created? Have you checked the test target membership for the RestKit library? – Wain May 04 '14 at 09:53
  • RestKit is included in the Test target. My object manager seems to be getting created properly (in the AppDelegate), but is `null` in `+ (instancetype)mappingForEntityForName:(NSString *)entityName inManagedObjectStore:(RKManagedObjectStore *)managedObjectStore` – Whoa May 04 '14 at 15:17
  • I'm also using MagicalRecord, not sure if that is of note. – Whoa May 04 '14 at 15:30
  • 1
    The app delegate is used by the test target? Note that the app delegate shouldn't play any part in this (its purpose it to manage app level events, not host some of your data controllers and associated logic). – Wain May 04 '14 at 15:51
  • Hmm, I see what you mean. I just use the app delegate to initialize the RestKit stack, and that code is getting run before every test case. It's not included in the Test target though... – Whoa May 04 '14 at 16:17
  • 1
    I ended up using this solution: http://stackoverflow.com/questions/15714697/unit-testing-in-xcode-does-it-run-the-app to stop the normal app delegate from running. Thanks for pointing me in the right direction. – Whoa May 04 '14 at 16:36

0 Answers0