当前位置:网站首页>day13--postman interface test
day13--postman interface test
2022-08-04 05:00:00 【Ning Mang】
I. Introduction to interface functions
2. Postman daily operation
1. Use of global variables (Globals)
Description: Usually, the parts we use together can be stored in all variables, and only need {{variable name}}, applicable to all interfaces
For example: mobile phone number attribution and weather query
2. Use of environment variables (Environment variables)
Description: Different environments in the company, configure the data of different environments, only need {{variable name}} is enough, the interface applicable to the current environment, such as different domain names (different IPs within the company)
3. Interface association
1: Interface association method: json extractor 
Implementation method: json extraction
// The return value is converted into a json objectvar jsondata=pm.response.json()console.log(jsondata)// extract value by json expressionvar doer = jsondata.result.cityconsole.log(doer)// set global variablepm.globals.set("cs", doer);
// Get the text content of the response bodyvar resbody = responseBody;console.log(resbody)// Convert to json objectvar jsonobj = JSON.parse(responseBody)// extract value by json expressionvar pro = jsonobj.result.provincepm.globals.set("prodes", pro);
Words:
Set the assertion on the first interface, get the content of the return body and convert it into a json object, extract the desired value through the json expression, set the value to a global variable, and use { in the second interface{variable name}} instead, implement interface association
4. Assertion
Description: Often used to compare expected and actual results
Several ways for Tests to respond to assertions(1) Status code: code is 200 (check whether the response header contains a certain value)(2) response body:contains string (check whether the returned result contains a certain string)(3) response body: Json value check (check whether a field in the returned result is equal to a certain fieldvalue)(4) response header:content-type header check (check whether the response header contains a certain value)(5) response time is less than 200ms (check whether the response time is less than 200ms)(6) response body:Is equal to string (check whether the returned result is equal to the string) useless
边栏推荐
猜你喜欢
七夕节,我用代码制作了表白信封
System design. How to design a spike system (full version transfer)
【一步到位】Jenkins的安装、部署、启动(完整教程)
docker安装mysql与宿主机相差8小时的问题。
【云原生--Kubernetes】Pod资源管理与探针检测
结构体函数练习
[21 Days Learning Challenge] Image rotation problem (two-dimensional array)
leetcode 12. 整数转罗马数字
深度学习之 10 卷积神经网络3
Shocked, 99.9% of the students didn't really understand the immutability of strings
随机推荐
Mobile payment online and offline payment scenarios
Simple operation of the file system
【C语言进阶】程序环境和预处理
The Shell function
Jenkins 导出、导入 Job Pipeline
Explain详解与实践
解决错误:npm WARN config global `--global`, `--local` are deprecated
【机器学习】21天挑战赛学习笔记(一)
How to dynamically add script dependent scripts
技术解析|如何将 Pulsar 数据快速且无缝接入 Apache Doris
C专家编程 第4章 令人震惊的事实:数组和指针并不相同 4.4 使声明与定义相匹配
For Qixi Festival, I made a confession envelope with code
基于gRPC编写golang简单C2远控
震惊,99.9% 的同学没有真正理解字符串的不可变性
7-3 LVS+Keepalived Cluster Description and Deployment
2023年PMP考试会用新版教材吗?回复来了!
使用Patroni回调脚本绑定VIP的坑
Deep learning -- CNN clothing image classification, for example, discussed how to evaluate neural network model
leetcode 12. 整数转罗马数字
离线采集怎么看sql执行计划