UIViewControllers play a central role in iOS code. They’re the main way for UIKit to call most of our code. Does that mean your view controller code is out of reach of unit tests? Nope, not at all.
After all, UIKit manages to load and call your view controllers. So unit tests can do the same. To write tests for a view controller, the test first needs to load it. This will open the door to all sorts of tests.
In this chapter, we’ll look at different ways tests can load view controllers. How you do this depends on how you like to write view controllers. You may use storyboards, XIB files, or straight code. After making a new project to hold this chapter’s experiments, feel free to jump to the section you need: