Fiddler-AutoResponder修改接口数据
2017-07-19 本文已影响359人
臂力棒在想
Problem
APP功能测试时,有些场景需要特殊的数据,如APP对极限值的处理,或是账单列表的时间需要显示刚刚、昨天、周几,这就需要接口返回不同的时间。更改数据库是一种方法,但不够灵活,一些复杂的场景也不好模拟。
Solution
-
被测APP的手机连接Fiddler的代理。
-
将待修改URL的Response保存一份,在此基础上修改,效率会快一点。
image.png
-
打开保存的Response文件,修改你要修改的信息,保存。
-
点击Fiddler右侧面板中的AutoResponder > 点击Add Rule,或直接将左侧的URL拖到AutoResponder面板中。
-
AutoResponder面板底部的Rule Editor中,选择修改后的Response文件。

ps:
测试iOS上的APP时,Fiddler显示修改后的数据返回都正常,但是APP端有时就是显示不出来数据或提示网络异常。
原因:iOS开发使用的网络框架的自身特性导致的,当Response中有Content-Length信息如Content-Length: 2453
,iOS会校验Response Body的长度是否是2453,如果修改的Response Body,增加或减少了一些字符,框架就会因为长度不符而提示异常。最近简单粗暴的方法是删除Content-Length☺。
