接口测试

  1. 定义:后台的代码提供的对外接入

  2. 与fiddler比较:可以并发执行,可以保留测试,可以选择性执行某些接口

数据传递

  1. 内容类型(Content-Type):表单form-data(默认)、文本、图片、json

  2. 接口测试流程:

    1. 获取接口文档(api文档)

1904-接口-postman1904-接口-postman

  1. 安装测试工具---postman、postwomen、jmeter、fiddler

1904-接口-postman

  1. 创建集合collection与request

  2. 1904-接口-postman1904-接口-postman1904-接口-postman1904-接口-postman1904-接口-postman1904-接口-postman1904-接口-postman

组装正常场景

1904-接口-postman

组装异常场景

1904-接口-postman

  1. postman变量

  1. 变量分类:

集合变量

环境变量

全局变量

集合变量只能用在定义的集合中,环境变量可以用在任意集合,使用的时候需要选择这个环境变量,全局变量定义后可以直接使用

  1. 添加集合变量

1904-接口-postman1904-接口-postman

  1. 添加环境变量

1904-接口-postman1904-接口-postman1904-接口-postman1904-接口-postman

  1. 添加全局变量 1904-接口-postman1904-接口-postman

 

  1. postman断言

6.1 添加断言

1904-接口-postman

 

6.2 断言类型

1904-接口-postman

 

  1. postman控制台查看请求响应

1904-接口-postman

  1. postman写入cookie

postman可以自动保存cookie数据,按顺序运行的后续的接口请求都会被postman自动配置该cookie

postman自动记录的数据,如果用户也写入了该数据,postman会将用户数据优先

1904-接口-postman

postman自动记录相关cookie,并自动填补记录的那个cookie

1904-接口-postman

1904-接口-postman1904-接口-postman

 

  1. postman导入导出脚本

postman是将数据保存到json文件中去了,导入导出都是针对的json文件

下图是导出

1904-接口-postman

下图是导入

1904-接口-postman

 

  1. postman 关联数据-提取响应数据赋值到变量中

将服务端返回的数据写到变量 1904-接口-postman

console.log() //在控制台打印信息

1904-接口-postman

JSON.parse() //将类json格式的字符串 类型转换成json类型数据

1904-接口-postman

pm.enviroment.set() //将某个数据传递到某变量中

1904-接口-postman

  1. postman批量运行接口

 

1904-接口-postman

1904-接口-postman

  1. postman参数化--从数据文件csv中提取数据

1904-接口-postman1904-接口-postman1904-接口-postman

 

postman组装接口用例:--两种方式

分场景进行组装接口

多场景共用一个接口,使用数据文件分场景(少组装,使用js来分情况判断用例测试结果)

相关文章:

  • 2021-12-15
  • 2021-04-02
  • 2021-06-18
  • 2021-09-23
  • 2021-11-09
猜你喜欢
  • 2023-03-22
  • 2021-12-18
  • 2021-10-14
  • 2021-11-10
  • 2021-12-11
  • 2021-12-04
相关资源
相似解决方案