Testing Asynchronously

Take another look at running the app. After the app appears, it takes a second or two for the web page to load. But from the test’s point of view, as soon as the app is up and running, it is ready to be tested. What’s happening is that we are testing too soon. We need a way to wait before we run our test.

What we need is asynchronous testing, the ability to test things that happen at unpredictable times. If we wanted to test that 2 + 2 == 4, or that a string has a certain value, we could do that right away, because the value would be there right when we asked for it. But with the web view, we don’t know when (or if) its contents will be set. Asynchronous testing lets us test these kinds of unpredictable events.

Prior ...

Get iOS 8 SDK Development, 2nd Edition 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.