当前位置:网站首页>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
边栏推荐
- Large chain best freight d audit with what software?What are the functions?
- 商城系统APP如何开发 都有哪些步骤
- 深度学习21天——准备(环境配置)
- Interesting Kotlin 0x0E: DeepRecursiveFunction
- redis中常见的面试题
- [Skill] Using Sentinel to achieve priority processing of requests
- 应届生软件测试薪资大概多少?
- 结构体指针知识要点总结
- 2.15 keil使用电脑端时间日期
- 转:管理是对可能性的热爱,管理者要有闯进未知的勇气
猜你喜欢
随机推荐
8.Haproxy 搭建Web集群
C专家编程 第4章 令人震惊的事实:数组和指针并不相同 4.2 我的代码为什么无法运行
深度学习环境配置
2023年PMP考试会用新版教材吗?回复来了!
Shocked, 99.9% of the students didn't really understand the immutability of strings
[C language advanced] program environment and preprocessing
DataTable使用Linq进行分组汇总,将Linq结果集转化为DataTable
For Qixi Festival, I made a confession envelope with code
2022年PMP考试延迟了,该喜该忧?
OpenGL绘制圆
转:管理是对可能性的热爱,管理者要有闯进未知的勇气
Simple operation of the file system
if,case,for,while
关于yolo7和gpu
中信证券网上开户怎么开的?安全吗?
C Expert Programming Chapter 4 The Shocking Fact: Arrays and Pointers Are Not the Same 4.5 Other Differences Between Arrays and Pointers
有趣的 Kotlin 0x0E:DeepRecursiveFunction
Turn: Management is the love of possibility, and managers must have the courage to break into the unknown
深度学习21天——准备(环境配置)
[21 Days Learning Challenge] Image rotation problem (two-dimensional array)