当前位置:网站首页>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 (校验返回结果中是否等于该字符串)使用
少 
边栏推荐
- sql语句查询String类型字段小于10的怎么查
- 烧录场景下开发如何进行源代码保密工作
- 文件系统的简单操作
- How to simplify the automation of modern e-procurement?
- Learn iframes and use them to solve cross-domain problems
- A Preliminary Study of RSS Subscription to WeChat Official Account-feed43
- There is an 8 hour difference between the docker installation of mysql and the host.
- How to systematically plan and learn software testing?
- ADC噪声全面分析 -03- 利用噪声分析进行实际设计
- QT 如何识别文件的编码格式
猜你喜欢
随机推荐
Jenkins 导出、导入 Job Pipeline
图像处理之Bolb分析(一)
拿捏JVM性能优化(自己笔记版本)
中信证券网上开户怎么开的?安全吗?
【机器学习】21天挑战赛学习笔记(一)
深度学习环境配置
结构体指针知识要点总结
2022 Hangzhou Electric Power Multi-School League Game 5 Solution
系统设计.秒杀系统
机器学习模型的“可解释性”
How to systematically plan and learn software testing?
"Introduction to nlp + actual combat: Chapter 8: Using Pytorch to realize handwritten digit recognition"
劝退背后。
技术解析|如何将 Pulsar 数据快速且无缝接入 Apache Doris
移动支付线上线下支付场景
如何打造一篇优秀的简历
Embedded database development programming MySQL (full)
Take care of JVM performance optimization (own note version)
转:管理是对可能性的热爱,管理者要有闯进未知的勇气
There is an 8 hour difference between the docker installation of mysql and the host.









