Newman Postman Tutorial: New & Fastest Way to Run the Postman Collection – DSMayank Sharma
Brief Description of Newman Postman
- Newman is a command-line runner used for running Postman collections.
- It allows users to run an existing Postman collection through the command line.
- Newman is a NodeJS module so needing Node in the system is a prerequisite
Installation of Newman
- Once Node is installed in the system the user can simply install the Newman node package using the command: npm install -g newman
- Once Installed user can validate the successful installation of Newman by checking the version using the command: Newman -v
Execution of Postman Collections Using Newman
- So the first step is to export your collection and environment variables from Postman.
- Now once the collection JSON is obtained, open a command prompt at the root location where the collection and env JSON file is stored and run the collection using Newman run command. Newman run <collection_name.json>
- To provide an execution environment, you can use the -e to specify a JSON or CSV file using Newman run command. Newman run <collection_name.json> -e <env_name.json>
- Moreover, The Newman Collection runner is completely similar to the Postman Collection runner and request executor. For requests having assertions, the assertions get validated as and when the request execution completes and the results of the assertion execution are displayed in the test summary at the end of the test run.
Good to Read:- Ultimate Goal & Key Objectives of Software Testing
How to Generate Reports Using Newman?
- Apart from running Postman collections through the command line Newman has the ability to generate Postman test results in an interactive manner.
- Well, Newman has support for this as well. There are some custom node modules available for generating Newman test execution reports using a Newman-HTML-reporter.
- This reporter is also a node module and has to be installed using the command npm install -g newman-reporter-HTML
- Once this node module is installed, this can be used along with the Newman run command Newman run <collection_name.json> -e <env_name.json> -r htmlextra
- The -r htmlextra flag, indicates the reporter to be used with the Newman collection run and creates an HTML-based report for the test execution.
Newman can be used for executing a number of test cases, Suites. Further, NEWMAN is built with extensibility in mind so that it can be well integrated with CI/CD tools such as Jenkins, etc.