MagicalRecord several truncates, "then cannot find data for a temporary oid"

654 Views Asked by At

Before each test, I'm trying to wipe data and re-create fixtures. The app crashes every time it hits MR_saveToPersistentStoreAndWait however with cannot find data for a temporary oid

[A MR_truncateAll];
[B MR_truncateAll];
[C MR_truncateAll];
[[FixtureLoader instance] loadDataInContext:[NSManagedObjectContext MR_defaultContext]];
[[NSManagedObjectContext MR_defaultContext] MR_saveToPersistentStoreAndWait];

Why is this happening?

1

There are 1 best solutions below

3
On BEST ANSWER

rather than truncate in tests, just use an in memory store and dump the store after every test. You'll not experience crashes, and it'll be far faster.

- (void)setUp {
    [super setUp];

    [MagicalRecord cleanUp];
    [MagicalRecord setupCoreDataStackWithInMemoryStore];
}