Are mocks bad?

Episode Clip • Free • Jan 18, 2023

This is an excerpt from episode “Modern SwiftUI: Dependencies & Effects”.

You may have heard that “mocks are bad” and that they cause you to test the mock rather than your application’s actual feature. That doesn’t have to be the case. It is totally fine to mock a dependency to a system that you do not control, such as the file system. You do not need to test that saving and loading with that dependency works (after all, that’s the mocked behavior!), but you should test how your application behaves when it tries to load or save data. For example, is data saved after each change to your app’s data? Or, if loading data throws an error, do you show an alert to the user?


Subscribe to Point-Free

👋 Hey there! If you got this far, then you must have enjoyed this post. You may want to also check out Point-Free, a video series covering advanced programming topics in Swift. Consider subscribing today!