当前位置:网站首页>技术分享 | 如何模拟真实使用场景?mock 技术来帮你
技术分享 | 如何模拟真实使用场景?mock 技术来帮你
2022-07-28 05:28:00 【叶赫那拉 赫敏】
mock 是一种通过代理修改请求与响应,从而辅助构造更多应用场景的工具。比如在工作中,可能需要 mock 第三方的回调给到测试人员测试的环境,从而更顺利的开展测试工作,也使得测试环境更接近真实的使用场景。
Charles 修改请求与响应
MapLocal
将指定的网络请求重定向到本地文件。
先保存接口返回数据,右键单击某接口->点击 SaveResponse ->选择 html 格式
对本地的 html 进行修改,将“百度一下”改为“霍格沃兹”
设置 charles 进行 map local,右键点击 Map Local->进入 Edit Mapping ->点击 choose ->选择修改后的 html->点击 OK
此时再次请求百度,则可以看到“百度一下”变为了“霍格沃兹”

在 Charles 的菜单中,选择 Tools->Map Remote 或 Map Local 即可进入到相应功能的设置页面。
MapRemote
是将指定的网络请求重定向到另一个网址请求地址。
1. 设置参数Toos->Map Remote

2. 查看访问结果,则会发现,www.baidu.com 会被重定向到 www.sougou.com
Rewrite 功能
Rewrite 功能功能适合对某一类网络请求进行一些正则替换,以达到修改结果的目的。
1. 打开 Tools->Rewrite,对内容进行替换,下面把页面中“我的关注”替换为霍格沃兹

2. 再次申请百度,同样,“我的关注”变为了“霍格沃兹”
推荐学习
「Python App自动化测试训练营」全面升级,资深测试开发工程师带你从0到1快速上手APP自动化测试,扫码可领取课程资料哦~

边栏推荐
- [pta ---- traversal of tree]
- How to store floating point data in memory
- NIO示例
- Array solution script
- Leetcode brush question diary sword finger offer II 053. Medium order successor in binary search tree
- [C language] string library function introduction and simulation
- Project compilation nosuch*** error problem
- OJ 1129 fraction matrix
- OJ 1020 minimum palindromes
- 网络——网络层
猜你喜欢

NFT data storage blind box + mode system development
![[dynamic planning -- the best period for buying and selling stocks Series 2]](/img/6c/887a026d3c1bcbd278bb7f3e0afd05.png)
[dynamic planning -- the best period for buying and selling stocks Series 2]

二维数组实战:螺旋矩阵

Personal understanding of Chinese remainder theorem

Source code analysis of countdownlatch of AQS

如何描述一个BUG以及BUG级别的定义、生命周期

关于时间复杂度,你不知道的都在这里

SSAO By Computer Shader(三)

RayMarching realizes volume light rendering

下雨场景效果(一)
随机推荐
战疫杯--我的账本
[queue, simple application of stack ---- packaging machine]
About the collation of shader keyword
软件测试的生命周期(流程)
mongoDB复制集及分片集群
费马小定理
Yapi vulnerability hanging horse program chongfu.sh processing
rancher部署实战
项目编译NoSuch***Error问题
Personal understanding of Chinese remainder theorem
OJ 1020 minimum palindromes
图形管线基础(番外篇)
Source code analysis of countdownlatch of AQS
How to simulate the implementation of strcpy library functions
Leetcode brush question diary sword finger offer II 055. binary search tree iterator
redis实现分布式锁思路及redission分布式锁主流程分析
OJ 1507 deletion problem
Code neatness (2)
How to store floating point data in memory
Project compilation nosuch*** error problem