Chapter 6Manage Difficult Dependencies

When you realize you can write unit tests against view controllers, it’s exciting. At first, you may think this will unlock your codebase to automated testing: “I can test anything!”

Unfortunately, as you try to make progress, you’ll experience setbacks and frustrations. Sure, you can write a test that accesses a particular view controller. But as soon as you try to have a test call some method, you find the code inside the view controller is fighting you.

This is true of any types, not only view controllers. Code written without tests often has implicit hardwired dependencies. These dependencies can complicate testing. It so happens that view controllers are especially susceptible to such problems. ...

Get iOS Unit Testing by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.