Running and Monitoring Postman API Tests
In the previous article, we talked about how to create test scripts for API automation and now we will talk about running and monitoring your tests.
In the first step, we created our test suit but how to run them and see a report of a collection runs. If you are asking what is a collection, it is your project folder that you store your API tests with a json format.
Here is my example, Sample Collection is a collection and you can also add folders to classify your API tests. You can reach the collection example from the following link.
If you wonder how this collection is stored you can open the .json file and it looks like this:
Running Collections with Postman Runner
We can send requests one by one, but sometimes you build a scenario that uses a variable from previous requests or you may have a conflict with previous requests in your collection when you run from top to bottom. You build a collection and want to see how a full run works, then you can use postman runner itself. To open Postman Runner, choose the collection and click on the Run button.
Runner gives you many options for how to run your API test. You can even perform a small load if you need, but of course, we cannot name it as a load test since you cannot send requests with threads and large numbers, etc.
What Postman Runner offers you?
- You can decide on which request to run and which not. You can choose all collection, a folder, or any request to run.
- You can decide on iteration number, so you can make a loop to run your test cases as many as you want. Here you can perform a small load as I mentioned before.
- You can create delays between requests and requests will be sent within a defined time interval.
- You can import an outsource file to use data.
- You can save run results and responses.
- You can decide to use cookies or not to use and save them.
- You can keep variable values or reset them after the run.
Automating Test Runs with Postman Monitor
When I run the prepared automation suite manually it doesn’t sound like automation at all. I prefer to run it periodically if possible and also prefer to run it each time when any change occurs related to the project or API. We can succeed the first one by Postman itself. Postman has a very useful tool to run API tests periodically and it is called Posman Monitor.
It is accessible from the Monitors tab on Postman UI.
You can create a monitor, run your tests periodically and see the graphical report of your monitor here. API test result details are also can be seen from run details. You can open run results by clicking on a run from the monitor graphic.
You can create and configure running periods and also you can have a report of your run details by email notification if you have any failures. Just click on the plus button to add a monitor and you will see the create monitor page.
Decide on your monitor name, collection to run, environment to use, and running configurations like in which period you want to run your API test. You can prefer weekly timer or daily timer and you can decide how often you want to run within that chosen period.
You can configure to receive an email notification if any failure occurs and also you can choose how many times you resend a request if fails etc.
Email notifications are very useful, and I also think that they are pretty cute.
What do we have?
We learned how to run a Postman collection from top to down and also we learned a good way to automate our runs periodically by using Postman Monitor. It also offers nice statistics by a graphical report and email notifications at the end of the day. I hope you find this article useful. Happy testing!