当前位置:网站首页>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 .
边栏推荐
- QLabel 跑马灯文字显示
- R language uses rchisq function to generate random numbers that conform to Chi square distribution, and uses plot function to visualize random numbers that conform to Chi square distribution
- ROS自定义消息发布订阅示例
- If you have any problems, you can contact me. A rookie ~
- R language uses the order function to sort the dataframe data, and descending sorting based on a single field (variable)
- Docker installation redis
- test about BinaryTree
- Afnetworking framework_ Upload file or image server
- 朗坤智慧冲刺科创板:年营收4亿 拟募资7亿
- R language ggplot2 visual time series histogram: visual time series histogram through two-color gradient color matching color theme
猜你喜欢
Word如何显示修改痕迹
Human bone point detection: top-down (part of the theory)
Tongyu Xincai rushes to Shenzhen Stock Exchange: the annual revenue is 947million Zhang Chi and Su Shiguo are the actual controllers
ORACLE进阶(四)表连接讲解
Self supervised heterogeneous graph neural network with CO comparative learning
深度循环网络长期血压预测【翻译】
If you have any problems, you can contact me. A rookie ~
Meilu biological IPO was terminated: the annual revenue was 385million, and Chen Lin was the actual controller
二叉搜索树
关于静态类型、动态类型、id、instancetype
随机推荐
Specify flume introduction, installation and configuration
Penetration test information collection - App information
The dplyr package of R language performs data grouping aggregation statistical transformations and calculates the grouping mean of dataframe data
如何提高网站权重
裕太微冲刺科创板:拟募资13亿 华为与小米基金是股东
Stm32+hc05 serial port Bluetooth design simple Bluetooth speaker
Collection of penetration test information -- use with nmap and other tools
Afnetworking framework_ Upload file or image server
[matlab] Simulink the input and output variables of the same module cannot have the same name
Qlabel marquee text display
Estimate blood pressure according to PPG using spectral spectrum time depth neural network [turn]
R language uses rchisq function to generate random numbers that conform to Chi square distribution, and uses plot function to visualize random numbers that conform to Chi square distribution
上海部分招工市场对新冠阳性康复者拒绝招录
基于ppg和fft神经网络的光学血压估计【翻译】
This article discusses the memory layout of objects in the JVM, as well as the principle and application of memory alignment and compression pointer
How word displays modification traces
Jdbc driver, c3p0, druid and jdbctemplate dependent jar packages
Multithreading Basics: basic concepts of threads and creation of threads
R语言ggplot2可视化:使用ggpubr包的ggstripchart函数可视化分组点状条带图(dot strip plot)、设置add参数为不同水平点状条带图添加箱图
R语言ggplot2可视化时间序列柱形图:通过双色渐变配色颜色主题可视化时间序列柱形图