当前位置:网站首页>postman接口自动化-3-Tests断言3:获取动态参数,设置环境变量(接口关联)
postman接口自动化-3-Tests断言3:获取动态参数,设置环境变量(接口关联)
2022-04-22 06:32:00 【花测试】
在章节 postman初级-3- header presets,解决请求头带token的问题 我们提到使用环境变量 token、uid
但是,token是有有效期的,过期又得重新去修改环境变量,这样接口自动化一点也不自动。那么问题来了,怎样自动设置环境变量?其实,这是接口自动化不可避免的问题,我们一定会遇到接口关联的问题。即:前面接口的响应结果里的数据,要作为后面接口的入参。
postman提供了环境变量设置的语法:Tests右侧提供了模板,点击一下就自动显示到左侧编辑区了。
获取(get)/设置(set)/清除(clear) 环境变量、全局变量等。
如下:如果测试用例执行成功,就将接口响应数据里的token、uid 添加到环境变量。这样,其他接口就可以直接引用这俩变量了。

附:
1、建议环境变量设置、清除,要在用例执行成功时再执行,否则容易把环境变量弄乱。
2、已存在同名的环境变量,设置时直接覆盖。
版权声明
本文为[花测试]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_48415452/article/details/119958642
边栏推荐
猜你喜欢

Help 2021 Hangzhou network security publicity week | collection of wonderful activities of Shiping information

Software development specification

Shiping information has successfully passed the evaluation of "capability verification of data security products" of China Academy of communications and communications

在window环境下面virtualbox加载移动硬盘里创建好的虚拟机

.Net5 Log4Net启动一段时间后记录日志到数据库中失败问题

MySql查询指定一行排序到第一行

Read iso15031 protocol data stream

About information collection

世平信息成功通过中国信通院“数据安全类产品能力验证”评测

The practical paper of Shiping information and data security compliance testing was selected into the Chinese core journals
随机推荐
Shiping information was listed in the panorama of China's network security market in 2021
flask 数据Model迁移报错
Echars dynamically realizes the scatter diagram and customizes the information prompt box
Industry application | the way of data security and compliance construction of government big data platform
昆仑通态 │ G系列屏如何与西门子300国产MPI适配器连接
为什么我那么看重文档命名?
Leaders of Hangzhou commercial password Application Association and their delegation visited Shiping for information exchange
MySql查询指定一行排序到第一行
On June 1st, write a poem
ik分词器-简单使用
世平信息上榜《CCSIP 2021中国网络安全产业全景图》
Charles使用之修改请求和响应的三种方式
专注数据安全,世平信息上榜中国网络安全行业全景图六大细分领域
Shiping information has successfully passed CMMI Level 3 certification
Ultra vires and business logic vulnerabilities
技术解惑 | PLC是如何执行中断?又是如何去应用的?
世平信息参与衡阳市“船山论坛”企业路演,畅谈数据安全,助力协同创新
Mysql索引的探索
Exploration of MySQL index
JS dynamically merge cells