Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to run single request from the collection in newman

i have a collection in postman contain a lot of requests is there any option in Newman to run specific requests from this collection rather than create new folder for the specific request and run

like image 852
mahmoud rabie Avatar asked Feb 04 '20 12:02

mahmoud rabie


People also ask

How do I run a collection in Postman Newman?

In the Postman app, click on the ellipses (…) next to the collection and select “Export” to download a JSON file of the collection. Similarly, you can download a JSON file of an environment if you're using one. In the same directory where the JSON file is saved, use Newman to run the collection from the command line.

Can Newman run multiple collections?

This allows us to run multiple collections defined in a single json file and run all the collections in one shot and have a combined reports at allure.

Can we execute single Postman collection with multiple environments?

Postman monitors only work with one environment. You would have to duplicate your individual collections, set the environment and duplicate the settings (alert emails etc.) to run your collections with different environments.

How do I run a collection runner in Postman?

Step 1 − Click on the Runner menu present at the top of the Postman application. Step 2 − The Collection Runner screen shall appear. Step 3 − Select the Collection name from Choose a collection or folder. Step 4 − Select an environment from the Environment dropdown to run the requests in a particular environment.


Video Answer


2 Answers

Yes, you can run a specific request in a collection runner in newman CLI with option --folder.

Documentation:

CLI option : --folder "name"

Run requests within a particular folder/folders or specific requests in a collection. Multiple folders or requests can be specified by using --folder multiple times, like so: --folder f1 --folder f2 --folder r1 --folder r2.

Example:

newman run "postman-collection-API" --environment "postman-environment-API" --folder request-name
like image 170
Hasna A.A Avatar answered Oct 23 '22 21:10

Hasna A.A


You can also run specific requests in the newman library as follows:

Documentation:

options.folder - The name or ID of the folder/folders (ItemGroup) in the collection which would be run instead of the entire collection.

Example:

newman.run(
  { 
    collection: 'postman-collection-API',
    environment: 'postman-environment-API',
    folder: ['request-name', 'other-request-name']
  },
  function (error, summary) {
    console.log(`${summary.run.executions.length} requests were run`);
  }
);
like image 1
Cameron Wilby Avatar answered Oct 23 '22 22:10

Cameron Wilby