In all chapters so far, the main focus was code that ran as part of an app. The apps you have worked on are small and can easily be tested manually. However, this approach doesn't scale well if your apps become larger. This approach also doesn't scale if you want to verify lots of different user input, lots of screens, convoluted logic, or even if you're going to run tests on many different devices.
Xcode comes with built-in testing tools. These tools allow you to write tests so you can make sure that all of the business logic for your app works as expected. More importantly, you can test that your user interface functions and behaves as intended in many different automated scenarios.
Many developers tend to shy away from testing and postpone it until the end of the project, or don't do it at all. The reason for this is that...