Thursday, February 2, 2017

Xcode 8.3: Waiting in XCTest

Joe Masilotti:

At first glance XCTestWaiter is simply a new approach to waiting for XCTestExpectations to fulfill. However, there are a few gems hidden beneath the surface.


A big advantage of this approach is that the test suite reads as a synchronous flow. There is no callback block or completion handler. The helper method simply returns a boolean indicating if the element appeared or not.


You are now completely in control of when and how to fail your tests if an expectation fails to fulfill. This enables waiting for optional elements, like a login screen or a location services authorization dialog.


Along with the new waiter class, XCTestExpectations was subclassed to make specific expectations a little easier to write.

Previously: XCTestExpectation Gotchas, Xcode 6.0.1 Asynchronous Tests, XCTest​Case / XCTest​Expectation / measure​Block().

Comments RSS · Twitter

Leave a Comment