当前位置:网站首页>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 (校验返回结果中是否等于该字符串)使用
少 
边栏推荐
猜你喜欢

manipulation of file contents

4-way two-way HDMI integrated business high-definition video optical transceiver 8-way HDMI high-definition video optical transceiver

For Qixi Festival, I made a confession envelope with code

Enterprise live broadcast is on the rise: Witnessing focused products, micro-like embracing ecology

【Ryerson情感说话/歌唱视听数据集(RAVDESS) 】

Introduction to mq application scenarios

JVM Notes

base address: environment variable

Shell 函数

如何简化现代电子采购的自动化?
随机推荐
centos 安装postgresql13 指定版本
深度学习环境配置
Hangdian Multi-School-Slipper- (tree map conversion + virtual point mapping)
机器学习模型的“可解释性”
"Introduction to nlp + actual combat: Chapter 8: Using Pytorch to realize handwritten digit recognition"
JVM笔记
How to open a CITIC Securities online account?is it safe?
The Shell function
元宇宙“吹鼓手”Unity:疯狂扩局,悬念犹存
7.LVS负载均衡群集之原理叙述
深度学习——以CNN服装图像分类为例,探讨怎样评价神经网络模型
mq应用场景介绍
一文详解DHCP原理及配置
SQL query String field less than 10 how to check
Senior PHP development case (1) : use MYSQL statement across the table query cannot export all records of the solution
Functions, recursion and simple dom operations
7-2 LVS+DR概述与部署
打造一份优雅的简历
Simple operation of the file system
2.15 keil使用电脑端时间日期