Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the method of association testing with postman interface?

Shulou Source: shulou.com Published: 2022-06-02 04:05:01 09月27日 Update

It is believed that many inexperienced people have no idea about the method of correlation testing for postman interface. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

Application scenario

Suppose the next interface login requires the return value of the previous interface. For example, a request needs to log in to obtain the token, and the next request must carry the corresponding token before the request can be made.

Method: by setting global variable / environment variable method 1: setting global variable

1. First request the login API. If the request is successful, return the corresponding token

two。 Set global variables through js under tests after the corresponding first step request is successful

# get the return value of the API var jsonData = JSON.parse (responseBody); # obtain the corresponding value according to your own API result level and set it to the global variable pm.globals.set ('access_token',jsonData.access_token)

After the request is set successfully, you can view the value of the global variable here

3. Send a second interface request, which can refer to the set global variable by {{access_token}}

Method 2: environmental variables

1. Add environment variabl

two。 Select the name of the environment variable and send a request to get token

Var jsonData = JSON.parse (responseBody); / / Environment variable assignment. Hh is my name. You can name it pm.environment.set ("hh", jsonData.access_token).

3. After sending the message successfully, you can see that the token value has been set successfully.

3. Select the same environment variable name, fill in the parameter name {{hh}} you just set, and send the request.

After reading the above, have you mastered the method of postman interface to do correlation testing? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Tags: Variables interfaces methods global environment success name login association test content more problem selection helpless for this reason reasons parameters available in the scenario Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Shulou Information Shulou Tech Info vpn Xiaomi