Use postman achieve mock test

mock test, derived from the English word fake, meaning false test

Those used to simulate the actual work in real-time back-end can not be connected, or not developed the back-end, used to obtain the results of one test mode feedback. After sending the request, the analog response content back to confirm the correctness of the return current system.

Below is achieved by postman mock tool

Requirements: To register before you can achieve

Strategy: Using mock-server configuration and set the appropriate environment variables private content, get mock-sever key AIP-key interface and create the interface name, url of the mock-server interfaces and API-key along with the key environmental variables added , create a new collection in the current request, the expected response result is provided in the example, mock-sever use environment variable url, and environment variables mock-server interface name and API-key into the request header ( header), the request is sent to obtain the expected results

1.  Create mock sever

 

 

2.  Enter the mock request and response settings, set up click next

 

 

3. Set mock server , enter the mock server name, the use of the environment, and arranged a private mock service, there is no suitable environment can choose NO Environment , click create

 

4. Click here to obtain mock interface key, landed browser settings, then click close

5. Click for key interfaces

6. Set the interface key name

7. show here mock interface key name and key code, you can turn on or off, you can also delete unwanted key

8. Back to the postman, was found in the right side of the collection collection that appeared to just name a named collection, click on the arrow in the upper right corner of the set, select mock, mock server address appears

 

 

 9. Click the drop-down box next to the upper right corner of the eye viewing environment, a new environment just name the same name

10. The drop-down box to select it, then click the eye next to look and found just saw the mock server with the url already go

 

 

 11. But this is not enough, click edit, add just the api-key, add formatting: VARIBLE = NAME VALUE = API-KEY, and save

 

 

12. The path just configured in mock server in the request interface and API-KEY input format in the header: KEY: x-api-key VALUE: {{NAME}}, to be consistent with the other parts of previously set click send, get results

 

 

 

 

 

 

 

13. New Collection under the current request, the request method, parameter, url custom, url To {{url}} / xxx / xxx format. header configuration x-api-key and {{name}}

 

 

14. After configured, example in the top right corner, a response corresponding to the configuration

 

 

15. Configure good save and return to the request page, click send, view the expected return results

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/wangx123sec/p/11494950.html