MagicalRecord.saveWithBlock({ context in
if let items = dictionary["items"] as? Array<NSDictionary> {
for itemInfo in items {
DBItem.findOrUpdateItemWithDictionary(itemInfo, inContext: context)
}
}
//is called
if let sets = dictionary["item_sets"] as? Array<NSDictionary> {
for setInfo in sets {
DBSet.findOrUpdateSetWithDictionary(setInfo, inContext: context)
}
}
}, completion: { finished, error in
completionBlock(error) //is not called
})
This is how I setup my core data stack:
MagicalRecord.setupCoreDataStackWithInMemoryStore()
The saveWithBlock:
method is executed asynchronously. The test might be finished before calling completion block though I do not know how is your test code.
Could you try to change the saveWithBlock:
method to saveWithBlockAndWait:
? It is executed syncronously. Or wait to execute asynchronous call with XCTestExpectation
?