We do interface testing with an assertion operation, and a variable is used frequently, which can be handled with environment variables.
Directory
1. The assertion of Postman
2. Environment variables of postman
1. The assertion of Postman
Also take Postman's login interface as an example, click the response Body:contain string on the right side of postman to see which strings are included in the last request interface and can be used as assertions, such as:
If you want to use the field of a response as an accurate assertion, such as a response to a Json string, click Response Body:json Value check on the right side of postman, then find the field you want to assert by using the JSON value method, and then process
2. Environment variables of postman
The first: variables are frequently used, such as IP and port numbers, and can be processed using environment variables.
Click the settings icon, add a variable, add a temporary environment variable, fill in the key and value, select the environment variable to add, call in {{XX}} format
Second: Temporary environment variables need each time a specific choice, more trouble, can be set to global environment variables
Same as adding temporary environment variables, but when added, select Globle to add, other consistent, but no specific selection
Third: sometimes want to extract the result of the last request as a parameter of the next request, this with the jpress delete interface as an example, first to get the new ID, and then to delete
The first step: fill in the following code in the test where you want to get the response result request
var jsondata = json.parse (responsebody);p ostman.setenvironmentvariable ("id", jsondata.data);
Step Two: Add environment variables
When you perform the delete interface, you can click Add, then Delete, or you may not succeed
Similarly, it can be set as a global variable in the form of other operations consistent with previous
Postman assertions/handling of environment variables