postman variables - environment variables, set of variables (variable project), global variables

 

postman version information:

Postman for Windows
Version 7.14.0
win32 6.1.7601 / x64
 
 
A: The environment variable: deal with different development environments, such as local, staging, different production environments requested address. The definition of a variable base_url
 
Example: Creating a production environment variable a:
Creation settings: Set - "add environment variables

 

VARIABLE variable   INITIAL VALUE default value   CURRENT VALUE current value

 

 Choose to switch environment - "Click eyes to see the current environment variable value

 

 

II: a set of variables (variable item): a request and a set of the following set directory may be used. The main use for a group request. For example, we can define a project as a collection, request token variable is defined as a set of variables.

Example: the definition of a set of test variables, and set the variable add ca.

Creating Settings: collections-> add collections (-> edit) -> variables

 

 

Three: global variables: request throughout the postman can be used.

Example: Create a global variable ga.

Create a set: variable settings - "global-" Add Variable

 

 

 

 

Four: Three variables

  1 in the request by using {{}} variable name, such as raw url address or call.

  Example: http://httpbin.org/get?a= {A} {} & CA = {{}} CA & Ga = {{}} Ga

 

 

 2 in Pre-request Script script and Tests

Pre-request Script variables may be provided, and will modify the value of current value.

Operating Environment Variables

pm.environment.get("variable_key");
pm.environment.set("variable_key", "variable_value");

集合变量操作

pm.variables.get("variable_key");
pm.variables.set("variable_key", "variable_value");

全局变量操作

pm.globals.get("variable_key");
pm.globals.set("variable_key", "variable_value");

 

 

 

 

 3 Pre-request Script和Tests 执行次序 

collection Pre-request Script -》 folder Pre-request Script -》 本次request Pre-request Script ===》请求 Request -》响应 Response ===》collection Tests -》 folder Tests -》本次request Test 

 

Guess you like

Origin www.cnblogs.com/heheisme/p/12194634.html