LinuxCommandLibrary

newman

Run and test Postman collections

TLDR

Run a collection (from a file)

$ newman run [path/to/collection.json]
copy

Run a collection (from a URL)
$ newman run [https://www.getpostman.com/collections/631643-f695cab7-6878-eb55-7943-ad88e1ccfd65-JsLv]
copy

SYNOPSIS

newman run collection [options]

PARAMETERS

-e, --environment file
    Path to a Postman environment JSON file to use for the run.

-g, --globals file
    Path to a Postman globals JSON file to use for the run.

-d, --iteration-data file
    Path to a JSON or CSV file containing iteration data for the collection.

-n, --iteration-count count
    Number of times to run the collection.

-r, --reporters reporter_name
    Specify reporter(s) to use (e.g., cli, json, html, junit). Multiple reporters can be comma-separated.

--folder folder_name
    Run only a specific folder or folders from the collection. Multiple folders can be comma-separated.

--insecure
    Disable SSL certificate validation for HTTPS requests.

--delay-request delay_ms
    Add a delay (in milliseconds) between requests in the collection run.

--bail
    Stop the collection run on the first test failure.

--suppress-exit-code
    Prevent Newman from exiting with a non-zero code even if tests fail, useful for CI/CD integration.

DESCRIPTION

Newman is a powerful and versatile command-line collection runner specifically designed for Postman. It enables developers and testers to execute Postman collections directly from the terminal, making it an indispensable tool for automating API tests and integrating them into Continuous Integration (CI) and Continuous Delivery (CD) workflows. By allowing the execution of comprehensive API test suites without the need for Postman's graphical user interface, Newman streamlines the testing process. It efficiently processes Postman collection JSON files, along with associated environment and global variables, and supports a wide array of reporting formats to output detailed test results, facilitating quick analysis and feedback on API health.

CAVEATS

Newman requires Node.js and npm to be installed on the system, as it is a Node.js package and not a native Linux utility. It operates exclusively on Postman collection JSON files, environment files, and data files, meaning it's highly specialized for API testing workflows within the Postman ecosystem. While powerful for automation, it doesn't provide a graphical interface for debugging requests or building collections, relying on the Postman desktop application for those tasks.

REPORTERS

Newman supports various built-in and external reporters to output test results in different formats. Common built-in reporters include cli (default console output), json, html, and junit. Custom reporters can also be developed and integrated, providing flexibility in how test outcomes are presented.

USAGE WITH CI/CD

Newman's primary strength lies in its seamless integration into CI/CD pipelines. By automating Postman collection runs, Newman allows for immediate and consistent feedback on API health and functionality during development and deployment cycles, ensuring API reliability and performance before reaching production environments.

HISTORY

Newman was developed by Postman to extend the functionality of the Postman desktop application into command-line environments. Its introduction significantly facilitated automated API testing and integration into Continuous Integration/Continuous Delivery (CI/CD) pipelines, enabling developers and testers to run Postman collections as part of their build and deployment processes. It has evolved alongside the Postman application, adding support for new features like various reporting formats and improved error handling, becoming an integral part of modern API development workflows.

SEE ALSO

postman, curl(1), npm(1), node(1)

Copied to clipboard