First, installation
Official website:https://www.getpostman.com/
postman is a chrome plugin tool that we can search and install via Chrome's store , and the installation will display a postman icon on the desktop.
Second, the advantages
1) Support use case management
2) Support functions such as GET, post, file upload, response verification, variable management, environment parameter management, etc.
3) Support Batch operation
4) Support use case Import Export
5) Support for cloud saving use cases "paid users"
Third, the default POSTMAN will bring a demo project called "POSTMAN Echo", there are various scenarios of use case demo
Iv. Use of
4.1. New Project
just click on the Add directory icon to the left to create a new root, the equivalent of creating a project, we can put a project or a module of the use cases are stored in this directory, and under the root directory we can also create sub-directories to the functional use case segmentation, see:
4.2. New Use case
Click on the right area of the + sign, add a blank use case template, you can also copy an existing use case to achieve the purpose of creating a new use case, 2 ways to see below:
4.3. Add request Information
New use case request is empty, need to add request information
1) Select a request method, such as: Get or post
2) Fill in the requested URL, such as: http://www.baidu.com
3) If it is get, the request parameter is written directly to the URL, using the? Connection
4) If it is post, the request is added to the body
5) Click "Send" to send the request
6) View Request Response content
Example of a POST request parameter:
The main feature of the POST request is that the request data is placed in the body, not the URL. See
The above example is the post mode transmission of ordinary parameters, if we need to send a request with a file, it is necessary to change the request format, as follows:
Note that the red box above must correspond to the
4.5. Add Request header information
Sometimes the request also need to add the specific header information, Postman also can perfect support, directly click on the headers tag to make the request header information settings
4.6. Pretreatment and result check
Preprocessing is mainly for the setting of some environment variables, which is equivalent to the initialization of data;
response processing is to analyze and verify the response results, such as checking if code is 200, whether the content is equal to a specific value, contains a specific value, and so on.
because the preprocessing and the result check are all using JS as the scripting language, we can also make arbitrary JS can implement the scene to assist the test.
4.7. Global variables and environment variablesGlobal Variables We can assign ourselves in 2 scripting environments for preprocessing and result processingin the specific test data we can be used directly, the specific use is: {{variable_key}}; For example, you can set a global variable in a script:postman.setglobalvariable ("username", "tester"); so in the case data item I can use this, {{username}}, to represent the specific tester value, see:
the environment variable is set and used basically the same as the global variable, just the environment variable we have another portal to set up, that is, environment configuration management,we can pre-establish a number of environment-related sets of variables, according to the actual test requirements before execution to select the corresponding environment variable template,This allows you to quickly switch the environment differences between the test server and the online server. For example: Configure 2 sets of environment variable template, a set of URL is the test environment, another set for the online environment, according to the test object different we choose different environment variable template is OK, and no longer need to modify the test data in the URL. We will extract the requested host, then use different URL values in different environment variable templates, and then we can make the corresponding request test by selecting different environment variable templates.
4.8. Export use case as codePostman another great place to go is the export use case is code, that is, if you write the use case, you can generate the code by clicking "Generate Code", and there are many languages and libraries to choose from.
4.9. Batch execution of Use cases
This feature is owned by a separate runner, which we need to operate in another interface, as follows:
Click on the button above will appear Runer interface, the following direct click "Start Run" can
Postman Testing the HTTP interface