CoreDataTestCase.model is a single instance only created once per static scope
Post
Replies
Boosts
Views
Activity
that's the static var
static var model: NSManagedObjectModel?
I check whether it's been created already and only initialize it if it hasn't
if let model = CoreDataTestCase.model {
mockPersistentContainer = NSPersistentContainer(name: "MySchema", managedObjectModel: model)
} else {
mockPersistentContainer = NSPersistentContainer(name: "MySchema")
CoreDataTestCase.model = mockPersistentContainer.managedObjectModel
}