DEV Community

Cover image for Postman Data Driven Testing using Newman CLI
Dilpreet Johal
Dilpreet Johal

Posted on

2

Postman Data Driven Testing using Newman CLI

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 –

newman cli data driven test run


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!

API Trace View

Struggling with slow API calls? 👀

Dan Mindru walks through how he used Sentry's new Trace View feature to shave off 22.3 seconds from an API call.

Get a practical walkthrough of how to identify bottlenecks, split tasks into multiple parallel tasks, identify slow AI model calls, and more.

Read more →

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay