Asynchronous Testing was made much easier in Xcode with the introduction of expectations and the XCTestExpectation class.In addition to the basic expectation support included are helper methods for testing KVO, Notifications, and using Predicates.Expectations are created by …

414 Testing in Xcode DF - devstreaming.apple.com

Asynchronous Xcode UI Testing - cleanswifter.com

For example, try to login with an invalid username and password, wait until the network communications are finished, then test that the user was not able to login. Swift has some nifty methods for testing these sort of things; the ones I use the most are expectationForPredicate and waitForExpectationsWithTimeout.