Using Alamofire in UI Test Target

蹲街弑〆低调 提交于 2020-01-02 09:28:15

问题


The below code snippet using Alamofire works fine in iOS app but the code does not work in iOS UI Testing target.

let configuration = NSURLSessionConfiguration.defaultSessionConfiguration()
configuration.HTTPAdditionalHeaders =   Alamofire.Manager.defaultHTTPHeaders
manager = Alamofire.Manager(configuration: configuration)
manager!.request(.GET, "https://www.google.com")
        .responseString { response in
            print(response.request)  // original URL request
            print(response.response) // URL response
            print(response.result)   // result of response serialization
            print("HTML: \(response.result.value)")
    }

The completion handler never gets invoked in UI Testing target.

If I add .progress block to request, that is getting executed, but the completionHandler still does not get executed.

Can someone please shed light on what I might be doing wrong.

来源:https://stackoverflow.com/questions/36949190/using-alamofire-in-ui-test-target

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!