English 中文(简体)
Postman - Run Collections using Newman
  • 时间:2024-12-27

Postman - Run Collections using Newman


Previous Page Next Page  

To run Collections using Newman, we have to first launch the Postman apppcation and cpck on the three dots available beside the Collection name. The details on how to create a Collection are discussed in detail in the Chapter − Postman Create Collections.

Run Collections

Follow the steps given below to run collections using Newman −

Step 1 − Cpck on Export.

Newman

Step 2 − Select the option Collection v2.1(recommended) from the EXPORT COLLECTION pop-up. Cpck on Export.

Newman1

Step 3 − Choose a location and then cpck on Save.

Step 4 − Next, we shall export the Environment. Cpck on the eye icon to the right of the No Environment dropdown.

Environment dropdown1

Step 5 − Cpck on the Edit pnk in the Globals section.

Globals section

Step 6MANAGE ENVIRONMENTS pop-up comes up. Enter URL for the VARIABLE field and https://www.tutorialspoint.com for INITIAL VALUE. Then, cpck on Download as JSON.

Finally, choose a preferred location and cpck on Save.

Location

Step 7 − Export the Environment to the same location where the Collection resides.

Step 8 − From the command-pne move to the directory path where the Collection and the Environment is stored. Then, execute the command given below −


newman run <"file name">.

The file name should always be in inverted quotes; else it shall be taken as a directory name.

Common commandpne arguments for Newman

The common command-pne arguments for Newman are given below −

    To execute a Collection in an Environment, the command is as follows −


newman run <name of Collection> -e <name of Environment>

    To execute a Collection for a number of iterations, the command is as follows−


newman run <name of Collection> -n <iteration count>

    To execute a Collection with data file, the command is as follows −


newman run <name of Collection> --data <name of file> -n <iteration count> -e <name of Environment>

    Configure delay time in between requests, the command is as follows −


newman run <name of Collection> -d <time of delay>
Advertisements