XCTest ファイルから、Web サービス呼び出しを呼び出して、「self.waitForExpectationsWithTimeout」API を使用して待機ブロックを配置し、サービス応答を取得しました。
このサービス応答で実行するテスト メソッドはほとんどありません。この応答をグローバル変数に保存し、他のテスト関数からアクセスすると、この変数は nil になります。ここで何をする必要がありますか?関数のパラメータとして渡すことはできますか?
let serviceResp :NSDictionary!
func test_One() {
//let expectation: XCTestExpectation = self.expectationWithDescription("HTTP")
datamanager.fetchData() //Web service
self.waitForExpectationsWithTimeout(5, handler: { (error: NSError!) -> Void in
//In 5 seconds, I will get response from service and will be stored in datamanager.response.
self.serviceResp = datamanager.response
})
}
func test_Two() {
//self.serviceResp is coming as nil even after assigning a value to it.
}
ありがとう