Run API tests in your CI/CD pipeline using Postman
Run API tests in your CI/CD pipeline using Postman
With continuous integration and continuous delivery (CI/CD), the goal is to deliver frequent software updates that provide value for users. At the same time, it’s important to maintain software quality. Running API tests automatically during the build process helps ensure that every code change is ready for production.
The Postman CLI enables you to run your test collections, monitors, flows, and more as part of your CI/CD pipeline. With the Postman CLI, you can run your tests and monitor their results every time there’s a push to your code repository.
Configure Postman CLI test runs
To run tests as part of the CI/CD pipeline, first create a Postman Collection with the tests you want to run. Then use Postman to generate a code snippet you can include in your CI/CD pipeline configuration. The Postman CLI runs your tests each time the pipeline runs. This enables you to push or roll back your changes based on the test results.
To configure your CI/CD pipeline to run a collection, do the following:
- Click
Items in the sidebar.
- Click Collections, select a collection, then click the collection or folder you want to run in your CI/CD pipeline.
- Click
Run.
- Click the Functional tab, then click Automate runs via CLI.
- Under Run on CI/CD, click Configure command.
- Select the collection you want to run and an optional environment. You can add multiple collections each associated with their own environment. Also select your CI/CD provider and operating system.
- Click Copy Postman CLI Command to copy the code. Then add this to your CI/CD pipeline configuration.
To learn more about configuring the Postman CLI in your CI/CD pipeline, see Postman CLI commands and options overview.