当前位置:网站首页>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 .
边栏推荐
- gin_gorm
- 【Proteus仿真】Arduino UNO +74C922键盘解码驱动4X4矩阵键盘
- 远程办公如何保持高效协同,实现项目稳定增长 |社区征文
- 微生物检测,土壤微生物的作用有哪些?
- Lecun, a Turing Award winner, pointed out that the future of AI lies in self-learning, and the company has embarked on the journey
- What will Web3 bring in the future?
- 【office办公-pdf篇】pdf合并与拆分让我们摆脱付费软件的功能限制好不好
- Thinking about business and investment
- Strictmode analysis activity leakage -strictmode principle (3)
- Open3d point cloud color rendering
猜你喜欢

Uniapp official component clicking item is invalid, solution

孙宇晨接受瑞士媒体Bilan采访:熊市不会持续太久

使用 C# 创造 ASCII 艺术

Log logrus third party library usage

PHP通过第三方插件爬取数据

One of the basics - overview of sta Basics

Institute of Microbiology, commonly used biochemical reactions in microbiological testing

QT5-布局在创作中的理解应用

【Qt5-基础篇】随机数显示屏展示

Exploration and practice of "flow batch integration" in JD
随机推荐
Log logrus third party library usage
Uniapp official component clicking item is invalid, solution
迪赛智慧数——其他图表(平行坐标图):2021年应届专业就业情况
More pragmatic in business
用 Flutter 的 Canvas 画点有趣的图形
3dsmax插件开发遍历节点对象和Object获取及INode变换矩阵说明
One of the basics - overview of sta Basics
Connectivity basis of Graphs
数字IC设计流程总结
[Qt5 basics] random number display
visual studio 2019 快捷键备忘
使用 C# 创造 ASCII 艺术
Note d'étude du DC: zéro dans le chapitre officiel - - Aperçu et introduction du processus de base
【qt5-tab标签精讲】Tab标签及内容分层解析
Introduction and principle analysis of cluster and LVS
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"?
QT5-布局在创作中的理解应用
What will Web3 bring in the future?
Qt5 mvc: revealing the secrets of data visualization
3500字归纳总结:一名合格的软件测试工程师需要掌握的技能大全