Suppose that you want to test a method like the following:
func doWorkInBackgroundWithCompletion(completionHandler: (Bool, NSError?) -> (Void))
This method takes a completion handler
which returns asynchronously, sometime after the function returns.
You would like to test that this function
does eventually call its completion handler,
and that when the completion handler is called,
it is passed
true for its first argument,
nil for its second.
The techniques that have been discussed so far in the chapter
do not allow for testing this method.
For testing an asynchronous method,
XCTest provides XCTestExpectation ...