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 })
Voici comment je configure ma stack de données de base:
MagicalRecord.setupCoreDataStackWithInMemoryStore()
La méthode saveWithBlock:
est exécutée de manière asynchronous. Le test peut être terminé avant d'appeler le bloc d'achèvement bien que je ne sache pas comment est votre code de test.
Pourriez-vous essayer de changer la méthode saveWithBlockAndWait:
Il est exécuté de manière synchrone. Ou attendre pour exécuter un appel asynchronous avec XCTestExpectation
?