Postman Data Driven Testing using Newman CLI

Dilpreet Johal
2 min readMar 2, 2023

--

API testing is a crucial aspect of modern software development, and data-driven testing is an effective technique to test APIs with varying input data. Newman CLI is a powerful tool that can be used to automate API testing and perform data-driven testing. Let’s see how we can do that –

What is Newman CLI?

Newman CLI is a command-line tool developed by Postman that allows you to run Postman collections from the command line. It provides a way to execute Postman collections in an automated and continuous manner, making it a popular tool for API testing and integration testing.

Prerequisites

  1. Create a Postman collection with the requests to be tested.
  2. Optionally, write tests for each request to validate the expected results.
  3. Export the collection so that it can be accessed by Newman CLI.
  4. Prepare a data file in CSV or JSON format to provide different input data for each test run.

How to do Data Driven Testing using Newman CLI?

To conduct data-driven testing with Newman CLI, you must execute the collection with the newman run command and then use the -d flag to provide the data file. Here’s an example:

newman run sample.postman_collection.json -d data.json

The above command will run all the iterations and return similar results –

To learn more, check out the video below –

Conclusion

Data-driven testing is a powerful technique to test APIs with varying input data. Newman CLI is a powerful tool that can be used to automate API testing and perform data-driven testing. With Newman CLI, you can easily perform data-driven testing and catch bugs and issues early in the development cycle.

👩🏻‍💻 Unleash Your Full Potential and Take Your Career to the Next Level with SDET-U Academy👇🏻
Join Academy

📧 Subscribe to my mailing list to get access to more content like this as well as be part of amazing free giveaways.

👍 You can follow my content here as well -

Thanks for reading!

--

--

Dilpreet Johal
Dilpreet Johal

Written by Dilpreet Johal

SDET Architect | YouTuber | Tech Blogger | Love to explore new tools and technologies. Get access to all the courses— https://sdetunicorns.com/