Skip to content

Logic Tests - Can't find entity #397

ski081 opened this Issue Jan 25, 2013 · 2 comments

2 participants

ski081 commented Jan 25, 2013

I'm running a plain old vanilla iOS logic test bundle (not application tests).

I followed Saul's article on Cocoa is my Girlfriend ( to set up the core data stack in memory. I get through the setup method, and it looks like the core data stack is ready to go.

I can print out a description of my model, and it includes the Person object. But when I try to run [Person createEntity], I get this:

+entityForName: could not locate an entity named 'Person' in this model

it's failing on:

+ (id)insertInManagedObjectContext:(NSManagedObjectContext*)moc_

I've got my core data model being compiled as ppart of my unit test bundle, but it can't find the entity.

For completeness, here are my setUp, tearDown, and test methods from my test class:

    [MagicalRecord setDefaultModelFromClass:[self class]];
    [MagicalRecord setupCoreDataStackWithInMemoryStore];

    [MagicalRecord cleanUp];

    // This is where it fails
    Person *firstPerson = [Person createEntity];

Any ideas on where I can begin troubleshooting?

ski081 commented Jan 25, 2013

Never mind - I had another test case that was creating the model improperly and not tearing it back down. This was overriding the setUp method in the other test case, since the core data stack already existed at that point.

Closing this issue.

@ski081 ski081 closed this Jan 25, 2013
fatuhoku commented Jul 3, 2014

+1 This happened to me too, so thanks for leaving that note!

Ended up having to binary chop through the test cases to find the offending one. Now all is good.

@Glavin001 Glavin001 referenced this issue in Streamlyne/ios-app Jul 22, 2014

Cannot load Entities when setting up CoreData #9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.