Asynchronous Testing

Writing concurrent code has many pitfalls and because of the inherit complexity, testing that code may also prove difficult. By leveraging XCTest, the test cases default to synchronous tests (i.e. when the test hits the last line in scope, it ends). Now, some developers may try to solve this by adding sleeps or manipulating the run loop, but those methods are unreliable or can cause side effects. To properly handle parallel scenarios, XCTest provides an API that allows you to create expectations for the outcome of an asynchronous operation by adhering to the XCTWaiterDelegate protocol....