iOS單元測試和UI測試全面解析(18)
發表于:2017-03-31來源:51CTO作者:朱先忠點擊數:
標簽:單元測試iOS
promise.fulfill() } dataTask.resume() //3 waitForExpectations(timeout:5,handler:nil) // then XCTAssertNil(responseError) XCTAssertEqual(statusCode,200) } 上面代碼中最關鍵的一點是,只需輸
promise.fulfill()
}
dataTask.resume()
// 3
waitForExpectations(timeout: 5, handler: nil)
// then
XCTAssertNil(responseError)
XCTAssertEqual(statusCode, 200)
}
上面代碼中最關鍵的一點是,只需輸入完成處理程序實現的期望——這需要大約一秒鐘即會發生。如果請求失敗,那么斷言也會失敗。
原文轉自:http://mobile.51cto.com/iphone-535758.htm