我想在
Quick/Nimble BDD测试中发出
@L_404_1@存根请求.
@L_404_1@有一个我使用JSON文件创建的sampleData参数:
var sampleData: Data { switch self { case .getPlaces: // Provided that project have a file named get_places.json in it's bundle. guard let path = Bundle.main.path(forResource: "get_places",ofType: "json"),let data = Data(base64Encoded: path) else { return Data() } return data case .getPlaceDetail: // Provided that project have a file named get_place_detail.json in it's bundle. guard let path = Bundle.main.path(forResource: "get_place_detail",let data = Data(base64Encoded: path) else { return Data() } return data } }
如何在测试中使用此参数?有什么想法在测试中发出@L_404_1@存根请求?
谢谢!
只需像在实际代码中那样使用您的提供商. Moya检测到当前目标是测试目标,并将返回样本数据而不是执行请求
原文链接:https://www.f2er.com/swift/319141.html