一个简单的postman实例

https://blog.csdn.net/zsj777/article/details/102456224,查找免费api

1、找一个免费的api,获取天气预报

http://t.weather.sojson.com/api/weather/city/101220101

2、get请求,设置变量,在pre-request Script设置

http://{{variable_key}}/api/weather/city/101200101

pre-request Script

console.log('1111')

postman.clearEnvironmentVariable("variable_key");

postman.setEnvironmentVariable("variable_key", "t.weather.sojson.com");

3、断言,在Tests里面

tests["Body matches string"] = responseBody.has("武汉");

断言成功

猜你喜欢

转载自www.cnblogs.com/mobies/p/11804664.html