Two series Postman: Postman explain the get actual Interface (interface test description, the interface testing process header field operation)

One: Introduction Interface Test

  Interface test: is the test, as well as the interface between each input and output logic test interface software to provide services for, verify the consistency of interface functions and interface description document.

  Interface testing benefits: interface test usually more thorough testing of the system, the higher guarantee product quality, while the earlier discovery of the underlying problems, modify and maintain the cost is smaller.

  Interface what to do test: The main transmission and reception through the tool or code to simulate http request when the interface test. Tools such as: postman, jemter, java + httpclient like. Interfaces can also be used to achieve automation, is implemented in code and UI Automation framework similar, by sending a request to the assertion determination.

  Interface Test procedure: 1. obtaining interface information: Called to obtain basic and returned through the interface and the interface document capture; 2 test Interface Design: The acquired interface information, according to the interface test parameters and design methods expected return result; 3 contract interfaces: passing parameters to the interface or programming tool; 4: returns information verification: obtaining the results returned by the interface, parsing and validation.

  Interface test request information four major concerns: 1. the URL requested; 2.Method methods; 3 request-header field (Request Headers); 4 parameter request (fetch the corresponding information in the Query String Parameters Postman the Request Body)...

  

Two: Postman get interface testing procedures (to Baidu ip interface as an example)

   1. Capture Baidu ip interface information, copy url address.

   

  2.打开Postman,新建一个request(两种方式,刚开始打开的时候直接选择Requset或者打开Postman后直接选择+号),选择get方法,填写url(复制url后发现会自动填充url栏下面的Params参数项)等,发送请求,查看结果,经过多次测试发现ip接口中两个参数(query、resource_id)必备,其余参数可有可无。

  

  3.对于百度ip接口,多试几条测试用例,与预期的结果做对比,发现两个必备的参数少了一个,会报参数错误,在ip前面多加一个.依然正确。

  

  4.测试结束后可以保存到创建的测试集中,也可以将结果导出,导出的格式是json格式,可以将文件分享给同事朋友让他们使用Postman也进行文件导入。

  

  

三:Postman get接口头域操作

  上面百度ip接口,发现不需要Headers信息,填了Referer也不会报错,但是有些接口缺少头域信息就会报错,得不到预期结果。在这里举例腾讯课堂评论接口,由于没有相关接口文档,就参考别的讲师测试的最后结果。

  Referer介绍:正确英语拼法是referrer。由于早期HTTP规范的拼写错误,为了保持向后兼容就将错就错了。Referer  是 HTTP  请求header的一部分,当浏览器(或者模拟浏览器行为)向web服务器发送请求的时候,头信息里有包含 Referer。

  Referer的作用:1.防止盗链;2.防止恶意请求。

  

四:Postman请求面板详解

  1.Postman Request四大要素

  

  

  对于Request Body选项解释如下:

  form-data:对应于Content-type的multipart/form-data类型,即可以发送键值对也可以进行文件参数传递,对于文件传递每次发送请求需要重新传入不保存文件信息,键值对不写入url,而是直接提交。

  x-www-from-urlencoded:对应于抓包信息中Content-type头域为x-www-form-urlencoded的类型,是以键值对的形式发送的表单参数,同时参数会携带在url中。

  raw:选中对可以使用请求体原始格式编辑各Content-type类型对应的参数格式,直接按请求体的格式来进行内容发送。

  binary:可以上传二进制文件内容。一次只能上传一个文件,也不能保存文件。

  2.Postman Response相应信息

  

 

Guess you like

Origin www.cnblogs.com/ttxcs/p/11322433.html