Automate Your API Testing by Scheduling Your Collection Runs on Postman

Today, many companies are offering APIs as products that are consumed directly or indirectly by end users. The “API-as-a-Product” strategy has revolutionized entire industries, and we are collectively witnessing the exponential growth of APIs and their strategic importance. Like any software product, APIs need to be tested before they are shipped to ensure that they are of high quality and able to deliver value for the business. Reliable APIs help you build trust with your users by avoiding unexpected behavior that can adversely impact your end user’s experience and, by extension, your business.

Postman enables you to manually validate that your APIs meet your expectations, so you can feel confident in the quality of your APIs. You can also script these validations into assertions and tests—and use Postman’s Collection Runner to run entire test suites in one go. Even if you’ve built high-quality APIs, you must regularly test them to detect defects and maintain reliability and contracts over time. Frequent API testing helps you maintain the trust you’ve built with your users and retain customers longer. But manually testing APIs on a periodic basis can be cumbersome and prone to human errors. Automated testing, in contrast, can increase your team’s productivity and ensure that your test runs are not missed or delayed.

That’s why we’re excited to announce that, as of today, you can automate your test executions by scheduling your collection runs on Postman Cloud.

Schedule your collection runs on Postman Cloud

The Collection Runner is a powerful tool that enables you to run an entire Postman Collection at once. These collections can contain tests for your endpoints, and you can even sequence your requests to create scenarios. With this release, you can now automate your periodic test executions by scheduling your collection runs at specified times and frequencies in the future—just like you use a cron job to automate your future periodic tasks.

Unlike Collection Runner runs, which happen on your local machine, scheduled collection runs will happen on Postman Cloud. This means they will use Postman’s infrastructure, so you don’t need to worry about failures or errors that occur due to the unavailability of your machine.

Configuring the scheduled run

You can now specify a frequency and time for your collection run executions. For instance, an execution can occur every day at 9 a.m., every Monday at 12 p.m., or even every 15 minutes. You can also pause your scheduled run and resume it at any time.

In addition to specifying the execution time and frequency, you can configure your scheduled collection runs to use different environment files. This enables reusability and helps you to test your APIs in beta, staging, and production. You can even use data files to test your APIs with different data points. As a bonus, you can also configure the order of your requests and schedule runs for any customized order, which we’ll discuss in more detail later in this post.

Finally, you can configure the scheduled run to send email notifications if there are any test failures or errors.

How to Automate your testing by scheduling collection runs

You can easily schedule your collection runs on Postman Cloud by following the steps below:

Step 1: Select a collection or folder containing your tests, click Run, and select Schedule Runs:

gif of selecting a collection or folder containing your tests

If you are new to writing tests in Postman, visit our Learning Center for more information.

Step 2: Give the scheduled run a name and set the frequency and run configuration. In the example below, we are scheduling the following collection to run every 10 minutes using the beta environment file:

gif of selecting a collection or folder containing your tests

Step 3: Select the email addresses that should receive notifications of run failures or errors. (By default, the email of the current user is prefilled.) Then, click Schedule:

gif of selecting a collection or folder containing your tests

Step 4: Your run has now been scheduled and is available under the Scheduled Runs section of your Runs tab within your collection. You can see the upcoming run here as shown below:

gif of selecting a collection or folder containing your tests

You can even choose to pause, resume, or edit your schedule from here by clicking on the menu options.

Step 5: Select the schedule and view the results of your automated runs that have been completed. In the below example, the first run was successful implying no test failures. The next three runs, however, have been failing due to test failures. You can also choose to manually trigger a run on Postman Cloud from here:

gif of selecting a collection or folder containing your tests

As seen above, the graph shows you all the completed runs sorted chronologically, with the most recent runs shown towards the right. You can view the trend of your response times and the failed tests.

You can learn more about scheduling collection runs here.

Debugging and fixing test failures

Debugging involves identifying which tests have failed and why, so that you can fix them. As discussed above, all of your scheduled collection runs are available under the Scheduled Runs tab in the Runs section of the collection.

Step 1: To debug a run that had a test failure, select the run and identify the tests that failed by filtering the failed tests:

gif of selecting a collection or folder containing your tests

Step 2a: You can use console logs to help you understand why an assertion failed. In the below console logs, you will notice that the user id returned by the get one user request was expected to be of type number. However, the response that was returned didn’t match that expectation, as it returned a string:

gif of selecting a collection or folder containing your tests

Step 2b:
You can also navigate to the given request and re-run it with the same environment file in order to reproduce the failure locally and check the response header or body:

gif of selecting a collection or folder containing your tests

Step 3: Once you fix the issue, you can either wait for your scheduled run or manually trigger a run on Postman Cloud to confirm that your fix has worked:

gif of selecting a collection or folder containing your tests

Getting notified when your tests fail

You can configure scheduled runs to send notification emails whenever there are any test failures or errors. This helps you save time by eliminating the need to manually check test results for failures. The email notification will contain information about which tests have failed, as well as a link to view the results in Postman:

gif of selecting a collection or folder containing your tests

How to schedule runs by changing the default order of the requests in the collection

Many Postman users use collections as repositories of requests, which they run in different sequences to represent different workflows or different variations of the same workflow. The Collection Runner already enables you to change the order of your requests—and even skip requests before running them. Similarly, when scheduling your collection runs, you can re-order your requests and save this custom order to be run on a schedule. This enables you to use the same collection to automate multiple test scenarios.

To customize a run order, follow these steps:

Step 1: Under Schedule Runs on the Collection Runner, change the order by dragging and dropping requests or skipping requests:

gif of selecting a collection or folder containing your tests

Step 2: Select the environment and other configurations as required and click Schedule:

gif of selecting a collection or folder containing your tests

Step 3: Check results and see the custom run order that is being executed in the results:

gif of selecting a collection or folder containing your tests

You can edit this order at any point by clicking the Edit schedule menu option. If a new request is added or deleted from the underlying collection, it will be indicated for your schedule. You can then choose to ignore these requests or add them to your run executions. In the below example, a new request was added:

gif of selecting a collection or folder containing your tests

Read more about changing request orders here.

Please note that the number of requests you can run as part of scheduled runs is counted towards your monitor usage.

We hope that you find this new automation useful. If you are interested in automating your API testing by continuously running your tests in CI Pipelines, read this blog post to know more about how you can use Postman CLI to achieve this.

As part of Postman v10, you can also try some brand new features, such as support for gRPC, API Governance, and a redesigned API Builder with native Git support. You can read more about Postman v10 in this blog post by Postman Co-founder Ankit Sobti.

Try Postman now


What do you think about this feature? Tell us in a comment below, or set up a time with a product manager to learn more. You can also give product feedback through our Community forum and GitHub repository.

Try Postman now

Comment

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.