Chapter 10: Testing Networking Code
Almost all iOS apps communicate with some kind of server to synchronize data to other devices or to provide additional features that are not possible on the iOS device alone. As the code of the server application is separate from the code of the iOS application, the unit tests for the iOS app should not test features implemented in the server application. The unit tests for the iOS app should only fail if the code of the iOS app has bugs.
To achieve that, the unit tests need to be independent of the server application. This separation has several advantages. The main ones are as follows:
- The unit tests are faster when they don't need to wait for the responses of the server.
- The unit tests do not fail because the server is not available.
- The networking code can be developed using test-driven development, even before the server application is available.
In this chapter, we will implement two different kinds of networking...