GYHttpMock
GYHttpMock copied to clipboard
Library for replacing part/all HTTP response based on Nocilla.
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json",@"text/json",@"text/javascript",@"text/html", nil]; //get请求 // SKIODriver * mockDriver=[[SKIODriver alloc]init]; // [mockDriver testUrl:urlString]; mockRequest(@"GET", @"https://www.baidu.com") .withBody(@"ceshi") .andReturn(200).withBody(@"{\"key\":\"value\"}"); [manager GET:urlString parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) { //数据请求的进度 }
首先引入头文件#import "GYHttpMock.h" 然后我调用 [[GYHttpMock sharedInstance]startMock]; # import "GYMockRequest.h" file not found 就报找不到头文件了,大神求解答一下 小弟,祈求大神出一个Demo吧,根本不知道怎么集成你这个框架,无比郁闷。。。。。。
mockRequest(@"POST", @"(.*?)dealer/login(.*?)".regex).withBody(@"{\"account\" : \"18621033332\"}".regex); 添加body后会crash 求指教
比如:http://jsonplaceholder.typicode.com/users GET 请求返回的是一个 Array, 而 `GYMockURLProtocol` 内部通过 `NSURLConnection sendAsynchronousRequest:` 请求得到的返回数据是通过 `NSMutableDictionary *result = [NSMutableDictionary dictionaryWithDictionary:json];` 进行解析的, 此时 `json` 是个 Array,导致了 crash。
使用cocopods配置之后,如果json文件在主app内,无法找到对应文件。
可以加上日志功能
方便测试查看请求log
能模拟 Service 端 setCookie 吗?或者以后可能会加上这个功能吗?
服务器返回的这种数据格式,withbody就会报错 ( { "a":1 } { "a":2 } )