Identify Difficult Dependencies

Now that we have some rules to gauge if a dependency is problem-free, let’s break each FIRE rule. This will help us learn which kinds of dependencies get in the way of simple tests.

F for Fast

iOS programs often include code that will execute in response to some external trigger. In later chapters, we’ll see how to unit test delegate methods. But if there’s no way for tests to trigger the code execution immediately, that’s a slow dependency. Examples include the following:

  • Calls to web services
  • Timers
I for Isolated

Dependencies break the rule of isolation in two common ways: global variables and persistent storage.

Global variables come in different varieties:

  • Variables defined outside of any type
  • Singletons ...

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.