当前位置:网站首页>Postman batch test interface detailed tutorial
Postman batch test interface detailed tutorial
2022-08-01 22:08:00 【Attack on cloud native】
介绍
postman
是一个谷歌出的轻量级的专门测试接口的小工具,虽然不如 firefox 的 poster 插件“轻量”,但是比 firefox 的 poster 插件、fiddler The interface test function is more comprehensive,比 Jmeter 更轻量、便捷~
postman 包括两种:Chrome 浏览器插件和 postman 客户端,我使用的是 postman 客户端
我比较喜欢postman
two function points,One is its batch execution、One is its view source function.
今天分享的是postman
如何批量执行接口测试用例,This will bring a lot of convenience to our work,比如我们写了几十个测试用例,Requests are all to the same address,但参数不同!postman
Help us solve this problem perfectly.
需求
I am going to access an interface,参数da
为20220701
到20220731
一个月的时间,即发送31
次请求.就可以利用postman
实现,See below for specific operations.
实践
新建一个名为batchDateAdd
的请求.访问的 GET 请求接口为:
http://blog.liabio.cn?da={
{
da}}
这里的{ {da}}
是变量占位符,will be filled with the actual value from the environment variable.
在 Tests Add scripts to tabs:
脚本内容如下:
var moment = require('moment');
var Num = pm.environment.get("Num");
var data = moment("2022-07-01").add(Num, "days").format("YYYYMMDD");
pm.environment.set("da", data);
Num++
pm.environment.set("Num", Num);
注意:这里用到 momentjs
新建一个名为testEnv
The environment variable group of.The environment sets the initial valueda
为20220701
,Num
为1
:
Will be used for the first requestda
This value populates the placeholder.At the same time, the above script will be executed,将da
值和Num
值修改,The modified value will be used next time.
Start a batch run,Click on the folderRun collection
:
Check the interface to be tested,and set the number of cycles,Each loop delay interval, etc,Here we enter the number of loops as 31
,点击 Run:
注意:请输入
31
,This and the screenshot1
不匹配
脚本中如果有console.log("hello")
can be viewed in the console,The way to open the console isView -> Show Postman Console
:
During the execution of the script, the environment variables are dynamically modifiedNum
和da
的Current Value
值:
After each test run,需要点击Reset All
,将Current Value
重置为Initial Value
:
Otherwise the next run will beCurrent Value
作为初始值.
交流
请关注微信公众号【进击云原生】,扫码关注,了解更多咨询,更有免费资源供您学习
边栏推荐
猜你喜欢
随机推荐
scikit-learn no moudule named six
MySQL related knowledge
03. GO language variable definition, function
如何理解 new (...args: any[]) => any
基于 OData 模型和 JSON 模型的 SAP UI5 表格控件行项目的添加和删除实现
找工作必备!如何让面试官对你刮目相看,建议收藏尝试!!
联邦学习入门
使用 Zokrates 在 BSV 上创建您的第一个 zkSNARK 证明
Unity Shader general lighting model code finishing
今年的很美味
VGUgarbage collector(垃圾回收器)的实现原理
线程池分析
HCIP---Architecture of Enterprise Network
xctf attack and defense world web master advanced area web2
小程序毕设作品之微信美食菜谱小程序毕业设计成品(5)任务书
威纶通触摸屏如何打开并升级EB8000旧版本项目并更换触摸屏型号?
AQS
kubernetes CoreDNS全解析
Deep learning Course2 first week Practical aspects of Deep Learning exercises
Ten years after graduation, financial freedom: those things that are more important than hard work, no one will ever teach you