当前位置:网站首页>day13--postman接口测试
day13--postman接口测试
2022-08-04 04:30:00 【宁氓】
一.界面功能介绍
二.postman日常操作
1.全局变量的使用(Globals)
描述:通常情况下,我们共同使用的部分可以存放在全部变量里,调用的时候只需要{ {变量名}}即可,适用 全部的接口
比如:手机号归属地和天气查询
2.环境变量的使用(Environment variables)
描述:公司中不同的环境,配置不同环境的数据,调用的时候只需要{ {变量名}}即可,适用当前环境的接口 比如不同域名的(公司内部不同的ip)
3.接口关联
1:接口关联的方式:json提取器 
实现方式: json提取
// 返回值转成json对象
var jsondata=pm.response.json()
console.log(jsondata)
// 通过json表达式提取值
var doer = jsondata.result.city
console.log(doer)
// 设置全局变量
pm.globals.set("cs", doer);
// 获取响应体的文本内容
var resbody = responseBody;
console.log(resbody)
// 转成json对象
var jsonobj = JSON.parse(responseBody)
// 通过json表达式提取值
var pro = jsonobj.result.province
pm.globals.set("prodes", pro);
话术:
将第一个接口设置断言,拿到返回体内容转成json对象,通过json表达式提取想要的值,将这个值设置全局 变量,在第二个接口中使用{ {变量名}}代替,实现接口关联
4.断言
描述:经常用于预期结果和实际结果的对比
Tests响应断言的几种方式
(1)Status code:code is 200 (校验响应头是否包含某个值)
(2)response body:contains string (校验返回结果中是否包含某个字符串)
(3)response body:Json value check (校验返回结果中某个字段是否等于某个
值)
(4)response header:content-type header check (校验响应头是否包含某个值)
(5)response time is less than200ms (校验响应时间是否少于200ms)
(6)response body:Is equal to string (校验返回结果中是否等于该字符串)使用
少
边栏推荐
猜你喜欢
[21 Days Learning Challenge] Image rotation problem (two-dimensional array)
See how DevExpress enriches chart styles and how it empowers fund companies to innovate their business
八年软件测试工程师带你了解-测试岗进阶之路
base address: environment variable
SQL query String field less than 10 how to check
RSS订阅微信公众号初探-feed43
机器学习之视频学习【更新】
小程序 + 电商,玩转新零售
Deep learning -- CNN clothing image classification, for example, discussed how to evaluate neural network model
Y86. Chapter iv Prometheus giant monitoring system and the actual combat, Prometheus storage (17)
随机推荐
Y86. Chapter iv Prometheus giant monitoring system and the actual combat, Prometheus storage (17)
目标检测-中篇
移动支付线上线下支付场景
42. 接雨水
Simple operation of the file system
Postgresql源码(66)insert on conflict语法介绍与内核执行流程解析
信息学奥赛一本通 1312:【例3.4】昆虫繁殖
How to systematically plan and learn software testing?
10 Convolutional Neural Networks for Deep Learning 3
2.15 keil使用电脑端时间日期
Enterprise live broadcast is on the rise: Witnessing focused products, micro-like embracing ecology
PHP高级开发案例(1):使用MYSQL语句跨表查询无法导出全部记录的解决方案
drools from download to postman request success
How to keep the source code confidential in the development under the burning scenario
How to dynamically add script dependent scripts
【Ryerson情感说话/歌唱视听数据集(RAVDESS) 】
Structure function exercise
基于 SSE 实现服务端消息主动推送解决方案
unity框架之缓存池
SQL injection in #, - +, - % 20, % 23 is what mean?