You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am running stub request test in XCTest and my case is as following:
func testExample() {
func matchPath(request: URLRequest) -> Bool {
let path = request.url?.path
return path != nil // setup a breakpoint on this line and you can see it runs twice
}
var responseBodyJson: [String: String] = [:]
responseBodyJson["appId"] = "1"
stub(matchPath, json(responseBodyJson, status: 200, headers: nil))
let urlPath: String = "http://www.stackoverflow.com"
let url: URL = URL(string: urlPath)!
let request1: URLRequest = URLRequest(url: url)
let response: AutoreleasingUnsafeMutablePointer<URLResponse?>? = nil
do{
let dataVal = try NSURLConnection.sendSynchronousRequest(request1, returning: response)
print(response)
do {
if let jsonResult = try JSONSerialization.jsonObject(with: dataVal, options: []) as? NSDictionary {
print("Synchronous\(jsonResult)")
}
} catch let error as NSError {
print(error.localizedDescription)
}
}catch let error as NSError
{
print(error.localizedDescription)
}
}
The text was updated successfully, but these errors were encountered:
I am running stub request test in XCTest and my case is as following:
The text was updated successfully, but these errors were encountered: