How to Mock and Stub a System Class in Swift

Episode 1

How to Mock and Stub a System Class in Swift: Part 1

Speed and reliability are key elements of a robust test suite. But for a test suite to be fast and reliable, you need to be in control of the environment in which the test suite is run. You don't want to write a unit test that depends on the response of an API request. Right? For such a unit test to be fast and reliable, the API your application interacts with needs to be mocked and its response stubbed.

Episode 2

How to Mock and Stub a System Class in Swift: Part 2

Remember from the previous installment of this series that our goal is to mock the Core Location framework and stub the responses of any geocoding requests we send to Apple's location services. This is necessary if we want to create a fast and reliable test suite. Being in control of the test environment is key if your goal is creating a robust test suite.