Ensuring App Quality with Tests

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 it's often pretty hard to figure out how to write proper tests. This is especially true if you're just starting out with testing. Lots of developers feel like large parts of the logic their tests validate are so obvious that writing tests for that logic just feels silly. When testing is not approached correctly, they can be more of a burden than a relief by being high-maintenance and not testing the essential areas of code.

This chapter serves as an introduction to writing both logic and interface tests using Xcode and its built-in tools. By the end of this chapter, you should be able to set up a robust suite of tests and understand how you can make use of the tools provided by Xcode to write better code that is testable and reliable.

This chapter covers the following two topics:

  • Testing logic with XCTest
  • Testing the user interface with XCUITest
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset