Sometimes during development, we want to test the interface by requesting it more than once. This blog briefly explains how to use POSTMAN.

First, define the dynamic value name of the parameter

Set the id parameter value to a dynamic value, as shown below,

2. Create a JSON file to store the test data

The following is an example of the JSON content:

 [{
 	"value":"apple"."id":"123"}, {"value":"orange"."id":"456"}, {"value":"banana"."id":"789"}, {"value":"pear"."id":"012"
 }]
Copy the code

The key names of the test data must match the dynamic parameter names defined on Postman

Three, custom test code

Customize the test code in the Tests TAB of the interface to be tested, or you can use Snippets for quick generation.

There are snippets to choose from on the right side of the Tests TAB

For example, select the “Status code: code is 200” script and quickly generate the following code to check whether the interface returns a 200 Status code

pm.test("Status code is 200".function () {
    console.log(JSON.parse(responseBody));
    pm.response.to.have.status(200);
});
Copy the code

Four, open Runner

Click the Runner button.

Tip: Before you start the runtime, save the interface you want to test.

Open the console

Select View from the menu bar and click the Show Postman Console.

Execute the request

First select the test interface, then select the JSON data file to test, and then click Run. For details, see the following screenshot.

7. Check the results

Looking at the test results at Runner,

View the request information on the console.