Post

Replies

Boosts

Views

Activity

New Core Data Stack (PersistenceController) in Unit Tests
With the new Swift App Xcode template, I see the PersistenceController struct was added with a shared and preview instance to serve as the Core Data stack. From what I understand, the preview instance is for SwiftUI previews. If I have a service class that takes an instance of my Core Data stack, should I be using the preview instance as part of my unit tests? Or should I create some sort of spy/fake to pass into the service class I am testing? In general, what is the best practices for testing classes that use Core Data?
1
0
837
Sep ’20