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?
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?