测试接口,postman和jmeter是用得最频繁的工具。

下面主要介绍postman测试http协议接口的用法,包含get,post(form-data,json,上传文件,cookie)。

postman--get请求

参数拼接在url后面

接口测试:postman

下面分别表示http响应状态码、请求耗时,响应大小,而上面的code=9630是程序内部定义的状态码

接口测试:postman

右上角code

接口测试:postman

接口测试:postman 

postman--post请求:form-data

接口测试:postman

cookies,response.set_cookie(username,token)

接口测试:postman

headers

接口测试:postman

右上角cookies

接口测试:postman

可以删除cookie

接口测试:postman

右上角code

 接口测试:postman

请求体里不同的input之间用一段叫boundary的字符串分割,每个input都有了自己一个小header,其后空行接着是数据

接口测试:postman

post请求--postman:x-www-form-urlencoded

接口测试:postman

自动添加上了请求头 

 接口测试:postman

cookies

 接口测试:postman

headers 

接口测试:postman

 右上角code

 接口测试:postman

将input的name、value用‘=’连接,不同的input之间用‘&’连接

 接口测试:postman

postman:上传文件

接口测试:postman

右上角code

接口测试:postman

接口测试:postman

postman:发json

接口测试:postman

自动加入了请求头信息

接口测试:postman

 右上角code

 接口测试:postman

接口测试:postman

postman:cookie中传token

token是登录返回的,add_user3这个功能必须先要登录

特别说明:实际测试过程中,如果token失效时间很长,可以像下面获取到token后写死;但是,最好是通过关联,动态获取

postman动态获取参考:https://www.cnblogs.com/uncleyong/p/10991383.html

此篇重点不是关联,所以token写死

请求头信息

接口测试:postman

 请求

接口测试:postman

右上角code

  接口测试:postman

可以看到,token在cookie中

接口测试:postman

postman:form-data,body中传token

接口测试:postman

右上角code

  接口测试:postman

请求内容

接口测试:postman

postman:json,body中传token

接口测试:postman

自动加上了请求头信息

接口测试:postman

右上角code

 接口测试:postman

接口测试:postman

 

至此,postman测试http协议接口的主要使用方法介绍完了。

postman更多功能,参考:https://www.cnblogs.com/uncleyong/p/10991383.html

接口测试:jmeter,请在公众号上查阅。

 

另外,

postman中 form-data、x-www-form-urlencoded、raw、binary的区别:https://blog.csdn.net/xybelieve1990/article/details/81111786

post使用form-data和x-www-form-urlencoded的本质区别:https://blog.csdn.net/u013827143/article/details/86222486

相关文章:

  • 2021-12-15
  • 2021-07-28
猜你喜欢
  • 2021-09-02
  • 2021-06-20
  • 2021-06-18
  • 2021-12-11
  • 2021-12-04
相关资源
相似解决方案