当前位置:网站首页>90% of test engineers use postman for interface testing
90% of test engineers use postman for interface testing
2022-04-23 00:08:00 【Jindu】
Catalog
One : Preparation before interface test
Four : The actual combat of interface test post Interface
One : Preparation before interface test
Interface test is a protocol based black box test , Before the interface test , We need to understand the interface information , Then I know how to test an interface , How to check the response value of the interface completely .

So here comes the question , Where can I get the interface information ? There are three common ways :
1. Through bag grabbing tools like fiddle,charles Get interface information
2. Through the browser developer tool ,networks View interface request information
3. Of course, the most direct and reliable is the interface document , This is the requirements document for the interface
A standard interface document should basically contain :
-
Interface request address 、 Request method 、 Request header information description
-
Interface input parameter description ( Including the type of parameter 、 If required 、 Length range, etc )
-
Interface response example 、 Response status code
Now many companies don't have interface documentation , But I don't have to worry about the importance of interfaces , I think testers should take the initiative , Development requires writing interface documents , We need to be more active in testing . Here's what I wrote swagger Interface documentation , You can refer to it :

Two : Interface test practice
Generally speaking, interface testing is based on testing tools at the beginning , Such as interface debugging postman, Development and testing use it to debug and test interfaces .
The interface of the demonstration part here is to use Flask Built Mock Serve, We will also share how to learn from 0 Build interface projects
Instance of a :demo
Interface information :
Address :127.0.0.1:5000/api/demo
GET type
Parameter is limit Not required , Indicates a data acquisition restriction
We turn on postman, request demo Interface , As shown in the figure :

This demo The interface does not need to fill in any parameters , And request header information , So the operation is very simple , Enter the interface address , Select the interface request method , Click on send Direct request successful , Or the response status code of the interface , And response values . Then if get The request has parameters. How to request parameters ? As shown in the figure :

stay Params Fill in the parameters in the form of key value pairs , We found that the interface response value at this time info The field has only one piece of data information , Of course limit by 2 when , Just go back to 2 Data . Careful friends may have found out get The parameters of the interface are directly spliced in url Back , Such as :http://127.0.0.1:5000/api/demo?limit=1,get Interfaces can also be requested directly in the browser , Get the response value

Software test fishing school :321255410【 remarks 777】
3、 ... and : understand cookie
Through an example 12306 Query the train number information interface to understand the cookie, Open the browser developer tool to get the interface address , Request method , Parameters , The response values are shown in the figure :

And then, like example one, in postman Enter the interface address and parameters , Send a request , however , Request failed , Children , Do you have a lot of question marks :

Then why is there no problem with this interface request in the web page , To postman It's a failure . In fact, when web When developers go to the back end to request this interface , It will send some website information to the browser , User's login status , User's browsing habits, etc Request Headers Medium cookie Pass to the back end , however postman Won't . Then I'll be postman It simulates adding request header information ( Header information is available in the browser ), As shown in the figure :

Sure enough, the request was successful , Isn't it interesting , Through two get Interface instance , Understand interface testing and cookie. So let's take a look at post Interface of type , By the way, understand the common token, This is also a common question in an interview , How to test the interface authentication
Four : The actual combat of interface test post Interface
Interface information : Address 127.0.0.1:5000/api/login POST type
Parameters username Represents the login user name
password password Represents the login password
Content-Type:application/json
As shown in the figure :

post Interface first select Body Parameters , Then enter the parameters to send the request . We can see the login interface if the request succeeds , So I went back to one token, It's like an ID card ID, Everyone has it. It's unique . The token It's this person's pass .
token authentication , Simply speaking , I just want to log in , Generally speaking , All interfaces of a system need authentication to request , In other words, first request the login interface of the system , Get the server response authentication , To request other interfaces , Usually put in the request header headers perhaps body In the parameters . If the request is not sent to another interface token You'll be prompted to have no access or log in
about http We have mastered the common protocol get and post The interface test , Of course, there are many other types of interface testing , such as delete,put etc. , There is also the participation for form-data Interface of type , For example, the file upload interface
So for interfaces with different protocols , such as webservice etc. ,dubbo Interfaces we all need to understand through examples . After understanding the various types of interface testing , So we can automate the interface , obtain A set of effective interface automation test scheme , According to the actual test requirements, we can build a test framework suitable for the project .
python Video for automated testing 、Python Automation details 、 Full set of interview questions and other knowledge content . You can join me if you need Software test fishing school :321255410【 remarks 777】, I hope I can help you on the road of self-study .
️ If this article is useful to you , Remember to praise and pay attention , Every praise you give me is taken seriously as like ~
️ See you next time !

版权声明
本文为[Jindu]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204222212380383.html
边栏推荐
- L1-065 nonsense code (5 points)
- 【ACM】90. Subset II (the de duplication problem of the same tree layer first needs to sort the array (use sort))
- L1-074 finish learning C language in two hours (5 points)
- PHP one-dimensional array de duplication
- Architecture of bar code WMS system
- Scheme of making target detection training samples
- Bonner ultrasonic sensor t30uxda
- L1-080 multiplication formula sequence (20 points)
- Reinstall windows10
- 根据角度进行旋转
猜你喜欢

Implementation method of interface between bar code WMS system and ERP

Interviewer: how big is the performance difference between ArrayList and LinkedList?

重新安装window10

Reg regular expression learning notes

Mysql中的七种常用查询连接详解

What kind of community play do you do?

Force deduction exercise set 2 -- addition of two numbers

BGP基本配置

A ConvNet for the 2020s的总结

FCOS中相较传统anchor-based方法中独特的地方
随机推荐
WMS仓储管理系统解决方案
Target detection model regression anchor offset and other problems
[VMware] VMware esxi 6.7 installation
Gets the color of a point
FCOS中相较传统anchor-based方法中独特的地方
图像感受野的一些理解
OC中常用的英文发音和注解
获取某一点的颜色
力扣习题集3--无重复字符的最长子串
Implementation method of interface between bar code WMS system and ERP
API interface knowledge summary
Compared with the traditional anchor based method, fcos is unique
邦纳超声波传感器T30UXDA
Force deduction exercise set 2 -- addition of two numbers
Ansible Yum warehouse
人为什么看不到事实?
[transaction management]
SystemVerilog verification - Test Platform writing guide learning notes (3): connecting design and test platform
庞加莱球模型
重新安装window10