Skip to content

Instantly share code, notes, and snippets.

@pangers
Created August 8, 2015 00:51
Show Gist options
  • Save pangers/891975f4a8b988bd5c88 to your computer and use it in GitHub Desktop.
Save pangers/891975f4a8b988bd5c88 to your computer and use it in GitHub Desktop.
class AsynchronousTesting: XCTestCase {
var clientManager: APIManager!
func setUp() {
clientManager = APIManager()
}
func testLongOperationCorrectly() {
var users: [Users] = []
let fetchExpectation = expectationWithDescription("Fetching list of users")
clientManager.getListOfUsers { incomingUsers, error in
if error == nil {
users = incomingUsers
XCTAssert(users.count > 0, "Users returned should always be greater than zero")
fetchExpectation.fulfill()
}
}
waitForExpectationsWithTimeout(5, handler: nil)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment