当前位置:网站首页>Interface test tool - postman
Interface test tool - postman
2022-07-06 19:00:00 【Another piece of braised meat】
Navigation
Why do we need interface testing tools
web There are many kinds of interfaces , such as Restful、Hessian、WebService wait , Those who have good development skills , Can build a project , With the help of HttpClient、WebResource、HessianProxyFactory Wait for the third party jar package , Even RestAssuerd Other framework , To realize the call of the interface .
Develop code to call interfaces , Has its advantages : Extensibility is strong 、 It can be more easily integrated into CI/CD In the process ; But its shortcomings are also obvious : More trouble . If you just need to call it quickly everyday , When testing its connectivity and other scenarios , Write a large string of code and wait for the project to compile 、 perform , Is too slow .
In daily work , In order to call the interface more conveniently and quickly , For example, some get Requested interface , I often call directly in the browser . But for more complex requests , Browsers are obviously not enough , So at this time, we need to call tools with the help of interfaces .Postman It is an interface calling tool , It is mainly used to simulate sending all kinds of HTTP request .
Postman install
Postman The installation of is relatively simple , It can be roughly divided into two installation methods :
1. Install to local application :
Go to Postman Official website , Download the installation program of the corresponding system , Complete the installation .2. With Chrome Plug in installation :
stay Chrome Browser , Found in the market of extension programs postman plug-in unit , Can be installed . You can also download the plug-in package , Install by local import .
The first method is more recommended , Install to local application . It is more convenient to manage the request collection 、 Custom request header 、 Check the history and so on .
Postman Basic operation
1. aggregate
On the left navigation bar ,Cllections The tab is the set management menu .Postman Collection management of , It's a directory structure , A set can be understood as a folder , And a request is a file . With the collection , We can put the same type of requests under a set , Easy to view .
Support to continue to add multi-level folders under the collection , This can make the hierarchical management of the interface clearer .
2. request
Postman The request in must be added under the set , And support all kinds of request methods .
After we create the request , Fill in the complete URL, And according to the interface input requirements , Fill in the request parameters .
stay Headers Under the tag, you can edit the data of the request header .
Body Various input formats are provided under the label , Support all kinds of common, such as web Forms form-data Format , And in raw Under Options JSON、XML Input parameters in equal format .
And can be found in Authorization Configure authentication information . And in the upper right corner Cookies in , Provides Cookies management function .
After filling in the request information , Just click on the Send Button , Then a request will be made , And get the response . The response information will be displayed below .
You can see the response status code in the upper right corner 、 Response time 、 Basic information such as response size .
And provides a variety of response body parsing methods , stay Pretty Next , The response message can be JSON\XML\HTML And other forms of beautification .
If the response is HTML Content , You can also do it in Preview Preview the rendering results .
3. environment variable
To make the request more flexible ,Postman It also provides the operation of variables . For example, when the input parameters of multiple requests need to be modified at the same time , Are assigned with variables , Then modify the environment variable , You can complete all the modifications .
There are two kinds of variables : Global variables (Globals)、 environment variable (Environment). Environment variables can rewrite and overwrite global variables , If there is no , Then the value in the global variable will be used .
When using variables , use { { Variable name }} Such a format is sufficient .
4. random number
With variables, we can't meet the changing needs , For example, when testing the payment interface , The serial number is unique every time , In this case , Use Postman Three random numbers provided , It can be well solved .
Postman There are three random number methods :
{ {$timestamp}}
: The current timestamp , Accurate to seconds{ {$randomInt}}
:0 and 1000 Random integer between{ {$guid}}
:V4 style GUID
Postman Scripting and continuous integration
Postman Support JavaScript, Can be in Tests Write scripts and assertions under the column , It will be executed before and after the request runs .
Postman Of Linux edition :Newman, You can run and test... Directly from the command line Postman aggregate . In this way, it can be integrated into Jenkins In the process , adopt shell Call the script to execute .
Automation of interface testing , I prefer to build Java or Python Engineering to achieve , So for Postman The application of this aspect will not be studied in depth for the time being , If necessary in the follow-up .
边栏推荐
- 二叉搜索树
- 关于静态类型、动态类型、id、instancetype
- Binary search tree
- [depth first search] Ji suanke: find numbers
- 用于远程医疗的无创、无袖带血压测量【翻译】
- R language ggplot2 visual time series histogram: visual time series histogram through two-color gradient color matching color theme
- Nuc11 cheetah Canyon setting U disk startup
- RedisSystemException:WRONGTYPE Operation against a key holding the wrong kind of value
- Penetration test information collection - basic enterprise information
- There is a sound prompt when inserting a USB flash disk under win10 system, but the drive letter is not displayed
猜你喜欢
MRO工业品企业采购系统:如何精细化采购协同管理?想要升级的工业品企业必看!
Breadth first traversal of graph
二叉搜索树
Deep circulation network long-term blood pressure prediction [translation]
用于远程医疗的无创、无袖带血压测量【翻译】
From 2022 to 2024, the list of cifar azrieli global scholars was announced, and 18 young scholars joined 6 research projects
巨杉数据库首批入选金融信创解决方案!
2022-2024年CIFAR Azrieli全球学者名单公布,18位青年学者加入6个研究项目
Tongyu Xincai rushes to Shenzhen Stock Exchange: the annual revenue is 947million Zhang Chi and Su Shiguo are the actual controllers
None of the strongest kings in the monitoring industry!
随机推荐
手写一个的在线聊天系统(原理篇1)
Penetration test information collection - WAF identification
Master Xuan joined hands with sunflower to remotely control enabling cloud rendering and GPU computing services
Bonecp uses data sources
Xu Xiang's wife Ying Ying responded to the "stock review": she wrote it!
2022.2.12
Summary of performance knowledge points
About static type, dynamic type, ID, instancetype
[paper notes] transunet: transformers make strongencoders for medical image segmentation
Docker installation redis
根据PPG估算血压利用频谱谱-时间深度神经网络【翻】
R语言dplyr包进行数据分组聚合统计变换(Aggregating transforms)、计算dataframe数据的分组均值(mean)
Handwritten online chat system (principle part 1)
With the implementation of MapReduce job de emphasis, a variety of output folders
青龙面板最近的库
Oracle advanced (IV) table connection explanation
Specify flume introduction, installation and configuration
Precautions for binding shortcut keys of QPushButton
Execution process of MySQL query request - underlying principle
提前解锁 2 大直播主题!今天手把手教你如何完成软件包集成?|第 29-30 期