Test your API using test collections and CI tools

Testing is a critical part of the API development process. You can create a collection that contains your API tests and link it to your API. You can also integrate your API with supported Continuous Integration (CI) tools.

Contents

Adding API tests

You can connect a test collection (a collection containing API tests) to an API you've defined in the Postman API Builder.

To add a test collection to an API, do the following:

  1. Select APIs in the sidebar and select an API.

  2. Select Test and Automation.

  3. Next to Collections, select + and select an option:

    • Add new collection - This option creates a new empty collection in the API. You can add your tests to the Tests tab.
    • Copy existing collection - Select an available collection from the list. A copy of the collection is added to the API.
    • Generate from definition - Change any settings to customize the new collection and select Generate Collection.
Adding a test collection

For more information on how to write API tests, see Writing tests.

Running API tests

After adding a test collection, you can run the collection to test your API and view test results.

To run a test collection for an API, do the following:

  1. Select APIs in the sidebar and select an API.
  2. Select Test and Automation.
  3. Under Collections, select Runner icon Run next to a test collection.
  4. Select any configuration options for the collection run, then select Run API Tests. Learn more about using the Collection Runner.
  5. To view detailed test results, expand the collection and select View Report next to a test run.
Running a test collection

To remove a test collection from an API, select the delete icon Delete icon next to the collection.

Adding CI integration

Postman integrates with some of the most widely used continuous integration and continuous delivery (CI/CD) tools. After you set up CI integration for your API, you can view the status of builds or start a new build, all from within Postman. You can also run API tests created in Postman as part of your CI pipeline.

To set up a CI integration for an API, do the following:

  1. Select APIs in the sidebar and select an API.
  2. Select Test and Automation.
  3. Under Automate, select the CI integration you want to add.
Connecting to CI/CD

To learn more about how CI integrations work, and for detailed configuration steps, see CI integrations.

Last modified: 2022/10/05