当前位置:网站首页>Test essential tool - postman practical tutorial
Test essential tool - postman practical tutorial
2022-07-01 01:36:00 【TEST_ Two black】
The interface test
(1) Server side (server): Using someone else's server , For example, wechat APP client , The server is on the server of Tencent , Account information on wechat , Chat records are stored on the server ; user A send out 1 Messages to the server , The server then forwards this message to the user B On .
The languages used by the server are :Java、Python、PHP、Go、C、C++ wait
(2) client (client): On the phone APP, Website
The languages used by the client are :object-c(IOS)、Android、HTML、CSS、JS wait
(3) Interface : Interacting with the server through the client
(4) So many languages , Cause unrecognizable , Common data types are needed for parsing :json{}, No, json Previously used XML Format
XML : Common data types
<title> The interface test
<content> The server and the client need interfaces to interact </content>
JSON : Common data types , Show as a key value pair :
{
"title" : " The interface test ",
"content" : " The server and the client need interfaces to communicate
}
How to test the interface
1、 Interface : The client and server interact , And the data returned by the interface is generally json The data type of the format .
2、 The basic steps of interface test are as follows :
In the interface documentation or elsewhere , Get the interface URL Address
See how the interface requests ( for example :get and post request )
Add request header , Request body
Send to see the returned results , Check whether the returned result is correct
3、 Open the interface document ( Reference resources :doc.nnzhp.cn)
(1)URL
(2) Request mode
(3) Request parameters
(4)get request
- On the browser , Directly enter the request in the interface document URL:
http://api.nnzhp.cn/api/user/stu_info, Page error prompt “ Required parameters are not filled in ! Please check the interface documentation !”( As shown in the figure )
- Based on url An error is reported if the link does not contain required parameters , Therefore, it is necessary to URL Fill in the required parameters :http://api.nnzhp.cn/api/user/stu_info?stu_name=%E5%B0%8F%E6%98%8E

When there are multiple required parameters , Need to be in URL Add other required parameters in “&” Splicing , for example :http://api.nnzhp.cn/api/user/stu_info?stu_name=%E5%B0%8F%E6%98%8E&age=25
machine learning PAI Console :https://pai.data.aliyun.com/console?regionId=ap-southeast-1&commodityId=&projectId=&deployFrom=&modelPath=&type=#/eas
(5)post request
Copy URL Open in browser , Report errors “ Wrong way to request ! Please check the interface documentation ”, For example, as shown in the figure

At this time, we need the help of postman Interface tools for testing , Prerequisite : Need to install locally postman Application software ( Be careful : If it is POST request , choice Params Fill in the parameters , At this time URL The parameter information will be automatically carried in , This request method should be GET Request mode instead of POST request , Pictured :)

POST request , You should choose Body Options , Check “form-data” perhaps “x-www-form-urlencoded” Fill in the required parameters , As shown in the figure :

POST request , User registration , Pictured :

POST request , The parameter for json type , Pictured :

Query whether the student information exists :

POST request ,Body choice form-data,Key from Text Switch File Format , Upload files ,( Be careful :x-www-form-urlencoded No, File Format , Only Text Options , Cannot upload multimedia files ) Pictured :

4、 The browser captures packets
(1) Browser open check or developer tools , Or check the console for elements
(2) Generally, view the calling interface Network( The Internet ) Below XHR Which interfaces are called
(3) request url:https://qun.qq.com/cgi-bin/qunwelcome/myinfo?callback=?&bkn=682554596

(4) utilize Postman The interface tool calls the interface :get_group_list

(5) Interface search_group_members , Interface test with multiple parameters :

(6)cookie and session
cookie: A key value pair that stores its own local information data in the browser (key-value) The place of
Storage time : Set as required
Save the location : client
session: A key value pair stored in the server
Storage time : User activity time + A delay time ( Prompt the user to save time when logging in 7 Days time )
Save the location : Server side
5、GET Request mode and POST Difference in request mode :
(1)GET The request has no body , Just request the header and URL:host/api/xxx?name=xxx
(2)POST A request has a request header 、 Request body
(3)GET The request did not POST Request security
(4)GET The request has a parameter length limit ,POST No,
postman Interface automation
1、 Test the bank project 、 Financial projects will encounter encryption parameters , need :
(1) Parameter remove encryption
(2) Provide a tool , Generate encrypted parameters
(3) Know the encryption algorithm by yourself , Then encrypt by yourself
2、Postman Manually configure the environment variables in the :
(1) stay Postman in , Yes Environment and Environment, For the management of different environments , Different server environments are :
Production Production environment
Development development environment
Local Local LAN environment
(2) Environment quick view , Pictured 1 Shown :

(3) Use Environment Implement multi service version management , Click on the settings in the upper right corner , Click on 【Manage Environments】, Sum graph 2 Shown :

(4) In the pop-up window 【MANAGE ENVIRONMENTS】 In the interface , In the lower right corner, click “Add”, Pictured :

(5) stay “Add Environment” in , Fill in the variable name and value , Pictured :

(6) After configuring the variable name and value , You can ask for URL Parameterization in :


(6) Write a script , Script parameterization , Like

(7) Click on runner, Configure operating parameters , Like :

(8) View the final running results , Status code for 200 ok, Indicates successful operation , Pictured :

There is a field in the figure that is :“This requests does not have any tests.”
Need to check :
First step : Check whether the variable name corresponds to ;
The second step : Whether you clicked save , Click again Runner
The third step : Whether verification has been added
(9) Add validation , Setup check

(10) postman Assertion :

(11) Click on 【Tests】 Button , There is one in the right column snippets bar , Inside is postman Built in test script , Auxiliary interface test :
A: Judge status code
Status code : Code is 200
The corresponding script :
B: Back to response Include content
Response body : Containing string
The corresponding script :
C: Back to json The value in the data
Response body : JSON value check
The corresponding script is :
D: The content of the response is equal to a string
Response body : is equal to a string
The corresponding script :
E: Check whether there is... In the response header Content-Type Field
Response headers : Content-Type header check
The corresponding script :
F: Judge that the response time is less than 200MS
Response time is less than 200ms
The corresponding script :

(12) Creating a new collection makes it easy to group individual requests , Pictured :

HTTP
1、http and https The difference :
- Different security :
http: ordinary http request ,, Message plaintext transmission message , unsafe ;
https: Having security ssl Encrypted transport protocol , Encrypt communication between browser and server , Ensure the security of data transmission ;
- The connection is different :
http The connection is simple , It's stateless ;
https By SSL+HTTP The protocol is built for encrypted transmission 、 Network protocol for identity authentication ;
- Different ports :
http agreement : The port used is 80;
https agreement : The port used is 443;
- Certificate application is different :
http agreement : Free application ;
https agreement : Need to ca Apply for a certificate , Generally there are few free certificates , You need to pay a fee .
2、 Generally complete URL by :http://192.168.13.3:80 host/ip:port/api/user/add_stu uri

3、 Interface HTTP Parameters
http Request mode :
get — By request URL Get resources
POST — For adding new content
PUT — Used to modify something
DELETE— Delete something
CONNECT— For proxy transmission , If you use SSL
OPTIONS— Ask what you can do
PATCH— Some document changes
PROPFIND(WebDAV)— View the properties
PROPPATCH(WebDAV)— Set properties
MKCOL(WebDAV)— Create set ( Folder )
COPY(WebDAV)— Copy
MOVE(WebDAV)— Move
LOCK(WebDAV)— Lock
UNLOCK(WebDAV)— Unlock
TRACE — For remote diagnostic server
HEAD — Be similar to GET, But not back body Information , Used to check whether an object exists , And get the metadata of the object
http Request header (headers)
The request header contains a lot of useful information about the client environment and the request body . As shown in the figure : For example, language category and status code
http Request body (body): The request body is the body of the request .json Format
xml Format
html Format
Binary format ( Mostly used for pictures )
String format
4、 The user interface can be through the following 4 Two different ways of asking to do different things :
(1) get data , use “GET” The way , Successfully returned HTTP Status code :200
(2) Create data , use “POST” The way , Successfully returned HTTP Status code :201
(3) Modifying data , use “PUT” The way , Successfully returned HTTP Status code :203
(4) Delete data , use “DELETE” The way , Successfully returned HTTP Status code :204
5、HTTP State :
(1) The request message (1 initial ) for example :100 Continue( Please continue to )
(2) The request is successful (2 initial ) for example :200 OK( Request succeeded )
(3) Redirect (3 initial ) for example :300 Multiple Choice( Multiple choice , A list of options is returned )
(4) Client request error (4 initial ) for example :400 Bad Request ( Wrong request ) 403 Forbidden( prohibit ) 404 Not Found( Can't find )
(5) Server error (5、6 The beginning of a word ) for example :500 Internal Server( internal error ) 502 Bad Gateway( The agent or gateway does not respond to the next link )
Detailed view HTTP Status code 、HTTP Status Code、HTTP Common status code queries :https://tool.oschina.net/commons?type=5
Here are some automation materials I sorted out. If you are interested, you can study together. Finally, I wish you all a happy ending The future is bright !!

These materials , For doing 【 software test 】 It should be the most comprehensive and complete war preparation warehouse for advanced friends , This warehouse also accompanied me through the most difficult journey , I hope it can help you !
Everything should be done as soon as possible , Especially in the technology industry , We must improve our technical skills .
边栏推荐
- Typora的使用
- Mysql database foundation: process control
- Uniapp official component clicking item is invalid, solution
- Solve idea:class' xxx 'not found in module' xxx‘
- 迪赛智慧数——其他图表(平行坐标图):2021年应届专业就业情况
- 测试必备工具-Postman实战教程
- php将二维数组元素转为键值对
- Visual studio 2019 shortcut notes
- 【Proteus仿真】Arduino UNO +74C922键盘解码驱动4X4矩阵键盘
- Service grid ASM year end summary: how do end users use the service grid?
猜你喜欢

Exploration and practice of "flow batch integration" in JD

Service grid ASM year end summary: how do end users use the service grid?

视频教程 | 长安链推出系列视频教程合集(入门)

zabbix如何配置告警短信?(预警短信通知设置流程)

流批一体在京东的探索与实践

Connectivity basis of Graphs

工作八年的程序员,却拿着毕业三年的工资,再不开窍就真晚了...

Typora的使用

3dsmax plug-in development traversal node object and object acquisition and inode transformation matrix description

flutter报错 -- The argument type ‘Function‘ can‘t be assigned to the parameter type ‘void Function()?‘
随机推荐
Typora的使用
TypeError: Argument ‘angle‘ can not be treated as a double
短视频平台开发,依靠DrawerLayout实现侧滑菜单效果
Why not two or four TCP handshakes
[simulation] 922 Sort Array By Parity II
Open3d point cloud bounding box
Unknown database connection database error
测试必备工具—Postman实战教程
农产品换房?“变相”购房补贴!
System. Csrebot for commandline
qt5-MVC:数据可视化的层次揭秘
New opportunities for vr/ar brought by metauniverse
日志 logrus第三方库的使用
基础知识之二——STA相关的基本定义
6月第4周榜单丨飞瓜数据UP主成长排行榜(哔哩哔哩平台)发布!
The liquor and tourism sector recovers, and Yaduo continues to dream of listing. How far is it from "the first share of the new accommodation economy"?
One of the basics - overview of sta Basics
laravel Carbon 时间处理类使用
工作6年,来盘点一下职场人混迹职场的黄金法则
Using recyclerreview to show banner is very simple