当前位置:网站首页>Variables in postman

Variables in postman

2022-07-05 01:53:00 @chameleon

Postman There are three variables in total

Postman Tool introduction and usage tutorial

One 、 environment variable

· Creation of environment variables
step :

1、 Click on postman Icon in the upper right corner
 Insert picture description here

2、 Click on “Add” Button , Then enter the name of the environment variable stay “VARIABLE” Enter the variable name of the environment variable in the column , stay “CURRENT VALUE” Enter the variable value in the column
3、 Click the bottom right corner of the interface “Add” Button to complete the creation of environment variables
· View environment variables
step :
1、 stay postman Click the icon in the upper right corner to select the name of the environment variable to view
 Insert picture description here
2、 stay postman Click the icon in the upper right corner , You can view the contents of environment variables
 Insert picture description here
· Environment variable reference
stay postman Click the icon in the upper right corner to select the name of the environment variable to view
 Insert picture description here

Use where reference is needed Two Curly braces hold Variable name Cover up . Format : { { Variable name }}

Two 、 Global variables

· Creation of global variables
step :
1、 Click on postman Icon in the upper right corner
 Insert picture description here

2、 Click on “Globals” Button
3、 stay “VARIABLE” Enter the variable name of the global variable in the column , stay “CURRENT VALUE” Enter the variable value in the column
4、 Click the bottom right corner of the interface “Save” Button to complete the creation of global variables
· View global variables
1、 stay postman Click the icon in the upper right corner , You can view the contents of global variables
 Insert picture description here

· References to global variables
step :
1、 Where variables need to be set , Use Two Curly braces Put the variable name Cover up , Format : { { The variable name of the global variable }}

3、 ... and 、 Set variable

Set variables can only be used in this set .
priority : environment variable > Set variable > Global variables

Project practice
step :
1、 Create a Collection( aggregate ) ---- Corresponding to project
· Click on the icon , Create set
 Insert picture description here

· Enter the set name , Click on “Create” Complete the creation of the collection
2、 Select the set created , Right click , choice “Add Fodler”, Create a folder — Corresponding to module
3、 Select step 2 Folder created in , Right click , choice “Add Fodler”, Create a folder — Corresponding to a specific interface
4、 Select step 3 Folder created in , Right click , choice “Add request”, Create a request ---- Corresponding to the use case
5、 First select the request method , Then enter the requested URL, Switch to Body Options Content-Type, Fill in the request parameters , And then in Tests Write assertions in , Click on “Save” Button to save the use case .
6、 Click... In the collection “…”, choice Run( Actuator ) To execute all use cases .

原网站

版权声明
本文为[@chameleon]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202141008352598.html