postman 自动化

1.准备测试数据

 第一行写参数名称

2.在Pre-request Script里面设置变量,用文件的数据给变量赋值:

 3.在request body 中引用变量

4.打开collection runner:

 然后点击运行。

如果要脚本的校验或者加token加入全局变量的化,需要在Tests添加

var jsonData = JSON.parse(responseBody);


tests["Responsetime小于200毫秒"]=responseTime<200;

postman.setEnvironmentVariable("access_token",jsonData.access_token)
postman.setEnvironmentVariable("userId",jsonData.userId)

原文地址:https://www.cnblogs.com/fyangq/p/13253750.html