当前位置:网站首页>Postman interface test IV
Postman interface test IV
2022-07-07 10:09:00 【Splendid Qianyang 813】
Catalog
Other easy-to-use functions and tools
Use environment variables to realize multi server version
Postman Support with Environment Environment variable to implement multi server version
Other easy-to-use functions and tools
grouping Collection
At the beginning of a project , For the convenience of organization and management , Multiple projects belonging to the same project API, Put it in a group
So we have to build a new one first Collection: New -> Collection

After a period of use , Built the effect of multiple groups :

The effect of expanding a single group :

Historical record History
Postman Support history Historical record , Show recently used API:

Use environment variables to realize multi server version
Existing problems
In the test API period , There are often multiple environments , Corresponding IP Address ( Or domain names )
such as :
Prod:
http://116.62.25.57/ucowsIt is used to release the development to the production environment
Dev:
http://123.206.191.125/ucowsFor online during development Development Test environment for
LocalTest:
http://192.168.0.140:80/ucowsIt is used for the local environment in the local LAN to cooperate with background developers during development , For joint debugging API Interface
While testing API period , It often needs to be modified manually API The address of :

Low efficiency , And after the address is changed, the address cannot be retained .
in addition , And according to different IP Address ( Or domain name ) It's not easy to identify which environment it is .
Postman Support with Environment Environment variable to implement multi server version
It turned out Postman in , Yes Environment and Global Variable, To solve this problem , Realize the management of different environments :

Obviously , Can be used to achieve without manual modification url Server address in , So as to dynamically realize , Support different server environments :
Production Production environment
Development development environment
Local Local LAN environment
How to use Enviroment Implement multi server version

perhaps :


Environments are a group of variables & values, that allow you to quickly switch the context for your requests and collections.
Learn more about environments
You can declare a variable in an environment and give it a starting value, then use it in a request by putting the variable name within curly-braces. Create an environment to get started.
Input Key and value:

Click on Add after :

[info] Where environment variables can be used
URL
URL params
Header values
form-data/url-encoded values
Raw body content
Helper fields
Write test In the test script
adopt postman The interface of , Gets or sets the value of the environment variable .
Here, put the previous in url Medium IP Address ( Or domain name ) Change to environment variable :

Move the mouse over the environment variable , Can dynamically display specific values :

Then add another development environment :

You can add 2 Environment variables , Indicates two server addresses , Two versions :

Then you can switch between different server environments :

You can see , Same variable server_address, After switching, it corresponds to IP The address becomes the of the desired development environment IP 了 :

Postman export API The effect of multiple environment variables in the document
Take a look by the way , Export to API After the documents , With this Environment Interface of variables , What does the document look like :
The discovery was before the release , You need to select the corresponding environment :



Published documents , You can see the of the selected environment and the corresponding server IP Of :

Of course, after publishing the document , You can also switch the environment in real time :


The benefits of environmental variables
When replacing the server , Directly modify the of variables IP Address :


It can be updated in real time , When the mouse moves over the variable, you can see the effect :

Code generation tool
View the currently requested HTTP Original content
For the current request , You can also click Code

Check the corresponding compliance HTTP The original content of the agreement :

Sample code for various languages Code Generation Tools
such as :
Swift Language

Java Language

Other languages It also supports various other languages :

Currently supported languages are :
HTTP
C (LibCurl)
cURL
C#(RestSharp)
Go
Java
OK HTTP
Unirest
Javascript
NodeJS
Objective-C(NSURL)
OCaml(Cohttp)
PHP
Python
Ruby(NET::Http)
Shell
Swift(NSURL)
The benefits of code generation tools are : Call this... When writing API When the code , You can refer to the corresponding code , Even copy and paste the corresponding code , that will do .
Test interface
After selecting a group , Click on Runner

Select a group and click Run

You can see the test results :

边栏推荐
- Before joining the chain home, I made a competitive product analysis for myself
- 2020 Zhejiang Provincial Games
- Software modeling and analysis
- ORM模型--数据记录的创建操作,查询操作
- [learning notes - Li Hongyi] Gan (generation of confrontation network) full series (I)
- 小程序实现页面多级来回切换支持滑动和点击操作
- Gym - 102219j kitchen plates (violent or topological sequence)
- Using keras in tensorflow to build convolutional neural network
- The physical meaning of imaginary number J
- Pit using BigDecimal
猜你喜欢
随机推荐
The physical meaning of imaginary number J
Become a "founder" and make reading a habit
C# Socke 服务器,客户端,UDP
2020CCPC威海 J - Steins;Game (sg函数、线性基)
flink. CDC sqlserver. 可以再次写入sqlserver中么 有连接器的 dem
小程序弹出半角遮罩层
Arcgis操作: 批量修改属性表
Scratch crawler mysql, Django, etc
一文讲解单片机、ARM、MUC、DSP、FPGA、嵌入式错综复杂的关系
ORM--数据库增删改查操作逻辑
Enterprise practice | construction of banking operation and maintenance index system under complex business relations
Performance optimization record of the company's product "yunzhujia"
小程序滑动、点击切换简洁UI
Google colab loads Google drive (Google drive is used in Google colab)
STM32产品介绍
Web3.0 series distributed storage IPFs
Basic chapter: take you through notes
[untitled]
Software modeling and analysis
C socke server, client, UDP








