How to automate api tests with the postman runner

Your question may already have an answer on the community forum. Please search for related topics, and then read through the guidelines before creating a new topic.

For the time being the runner seems not to be able to automate api tests - any experiences?

Hi @London890!

When you say automate, are you referring to running a Collection automatically? This is something monitors are perfect for. Alternatively, you could use Newman if CLI is more your style.

1 Like

Hi @London890 :wave:t4:

I wanted to take this time to show you a couple of ways you could go about automating your tests using the postman runner.

The postman collection runner is a powerful tool that allows you to run all of your tests in specified sequences. With that said, I wanted to share with you 3 specific examples and some more resources to get you started.

Example 1
In this example, I will show you the most simple way you can go about automating your tests using the postman runner.

I will be using the Intro to writing tests - with examples collection which you can fork into your own workspace.

Once you have this collection forked, the simplest way to use the runner is by clicking on the 3 dots next to your collection which should open up the runner tab. Alternately, you can also click Runner at the bottom right of Postman and drag a collection over.

You should see all of your request in the column and you can use this time to change the sequence of order of each request by dragging moving the requests before you click Run.

After you click Run, you should be able to see the summary and results of all of your tests. You are also able to export these results into a JSON file.

Learn more about the Collection Runner here : https://learning.postman.com/docs/running-collections/intro-to-collection-runs/

Example 2
In this example, I will show you how to run your tests using Newman CLI. Newman is a command-line runner for postman.

The first thing you will need to do to get started is to install Newman from npm globally.

npm install -g newman

Once you have Newman installed, you can export out and rename the collection from example 1 to where you want it locally and then use newman to run.

newman run mycollection.json

Learn more about Newman here : https://learning.postman.com/docs/running-collections/using-newman-cli/command-line-integration-with-newman/

Example 3
In this final scenario, I will be using @Joyce ‘s example to loop through a data file using the runner. Joyce has written a wonderful blog on this concept

I will be using her ramen example. You can read more about the collection and docs here : Working with data files: ramen

Essentially once you have downloaded the data file you can load the file into your runner and run your test. If the data is loaded correctly you can also preview it as well.

You should then be able to see all the results of your tests

I hope these examples give you more insight into working with the collection runner. Feel free to check out these resources