postman interface test

The postman tool is similar to other tools, how to encapsulate the http request will not be repeated here

1. Collections

1. A collection is a test project (in fact, a collection is a first-level folder), and a new subfolder can be created under the collection

2. Interface use case organization, the subfolder under the collection can be used as an interface, and multiple http requests are used under this folder (different use cases designed for this interface)

 

2. Environment variables

1. Globals Envrironment, which is valid for all environments

2. Define your own environment variables, which are valid only when running in the test environment

3. The reference of environment variables in postman is the same as that of loadrunner, using {{variablename}}

 

 3. Association technology in postman

When a certain http request data depends on the response data of another request, it is necessary to use the association

In postman, you can extract the required value in the response of the request in the tests input box, and implement it through setGlobalVariable / setEnvironmentVariable

Such as: pm.environment.set("variable_key", "variable_value"); In terms of the required data is stored in a variable

Then in the http request that needs this value, refer to it by {{variable_key}}

 

3, affirmation

Assertions for each interface are also made in tests

Format:

tests["checkpoint description"] = boolean expression

It can be asserted through the right prompt

The return data in json format

  json value check, value by level, parent object name. child object name, or parent object name [child object name]
  Helper function: convert xml to json

 

4. Log function

Logs can be printed using the console.log() function

View in the menu bar ----->> View ----->> Show Postman Console

 

5、Pre-request Script

Data processing before the request, such as request data encryption, data initialization, etc.

 

6、Collection Runner

To run all interfaces under a project, you can use Runner

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325112862&siteId=291194637