The Reimagined API-First Workflow, Part 2: for Testers
Tags: api, programming, tutorial
Published: 2021-12-03 10:19:12

---
title: The Reimagined API-First Workflow, Part 2: for Testers
published: true
date: 2021-11-30 00:34:38 UTC
tags: api, programming, tutorial
canonical_url: https://blog.postman.com/the-reimagined-api-first-workflow-for-testers/
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mzlwk0v3pj45yavsom8x.png
---

_This article was written by [Abhijit Kane on the Postman Blog](https://blog.postman.com/author/abhijitkane/)._

API testing has been a key part of Postman’s value proposition from day one. And with the new [Postman API Platform](https://www.postman.com/product/what-is-postman/), our testing abilities have gotten a major boost with features that help address a stronger focus on API quality. [Postman Collections](https://www.postman.com/collection/) (representing documentation, mock servers, and test suites) are [synchronized with the repository](https://dev.to/jansche/the-reimagined-api-first-workflow-part-1-for-developers-3e63-temp-slug-6815297). This means that API-first testing based on Postman Collections is possible without going out of Postman’s workflow, while also relying on the CI/CD tools that you’re already used to.

In this post, we’ll use a combination of Postman’s collection runner, command-line companion ([Newman](https://learning.postman.com/docs/running-collections/using-newman-cli/command-line-integration-with-newman/)), and CI/CD tools to add a layer of testing to our “Hello API-first world” API created in the [last post](https://blog.postman.com/the-reimagined-api-first-workflow-for-developers).

Let’s set up the test workflow and the integration with CircleCI:

1. Head over to the **Test** tab of any of your API’s versions: this is where most of your test workflows will live. Ensure there are test collections added to the API. [Powerful scripting and asynchronous capabilities](https://learning.postman.com/docs/writing-scripts/test-scripts/) let you test many aspects of an API’s behavior. If you want to ensure the correct message is returned each time, here’s how you might assert that in a request:  
 ![](https://blog.postman.com/wp-content/uploads/2021/11/Screenshot-2021-11-29-at-2.47.15-PM-300x179.png)
2. These tests can be executed in Postman against an environment of your choice—perhaps local for the developer or beta for the QA team. With Postman v9, there’s a single **Test**  interface where you can add collections and view recent collection run results.  
 ![](https://blog.postman.com/wp-content/uploads/2021/11/api-test-tab.gif)
3. If you add API tests in a new collection, make sure you add it to the API and [push to the underlying repository](https://learning.postman.com/docs/designing-and-developing-your-api/versioning-an-api/#pulling-and-pushing-changes). Adding the collection can be done via the **Add Test** link in the test tab.  
 ![](https://blog.postman.com/wp-content/uploads/2021/11/Screenshot-2021-11-19-at-2.45.06-PM.png)
4. You can use [Newman](https://learning.postman.com/docs/running-collections/using-newman-cli/command-line-integration-with-newman/) in your CI system to ensure that the tests are run with every push to the repo. If you’ve set up the integration with Git as described in [part 1](https://blog.postman.com/the-reimagined-api-first-workflow-for-developers), you’ll find the test collections in the `/postman/collections` directory in your repository. You can reference the collections directly from the repository tree—this enables you to test APIs across branches and aligns with the [branching support](https://learning.postman.com/docs/designing-and-developing-your-api/versioning-an-api/#switching-branches) that Postman provides.  
 ![](https://blog.postman.com/wp-content/uploads/2021/11/Screenshot-2021-11-19-at-2.50.02-PM-1024x887.png)
5. The integrations with CircleCI and TravisCI let you view the status of your pipelines right in Postman. You can view builds and their status across branches, and even trigger builds from Postman. In our example, we set up a CircleCI pipeline for our project. This is what the last few runs of the pipeline look like (you can spot Newman executing our tests collection, as well as some unit tests we added):  
 ![](https://blog.postman.com/wp-content/uploads/2021/11/Screenshot-2021-11-19-at-2.50.56-PM-1024x538.png)
6. To set up the integration:
  1. Head over to the **Test** tab for the API version, and select the CI/CD tool you use. In this example, we’ve used CircleCI.
  2. Enter your personal access token. For CircleCI, [https://circleci.com/docs/2.0/managing-api-tokens/](https://circleci.com/docs/2.0/managing-api-tokens/) describes how you can generate a token. This is what Postman uses to pull relevant data. Set a nickname that helps you identify your integration, and the project that you want to show builds for.
  3. You’ll see a list of recent builds, with the branch they ran on.
  4. Use the **Run Build** link to trigger a build on a specific branch. This can be done by developers when collections are updated in Postman. If you’re using the new Git integration described earlier, the pipeline will run automatically when code is pushed, or collections are updated and pushed.

This workflow helps to visualize build health as a property of the API. Links to CI/CD projects, which might be spread across wiki pages or internal documentation are now consolidated under one API construct, with easy navigation to the source code and interfaces that define the API.

Once the test workbench is set up, making changes to the API’s interface might involve the following steps:

1. Switch to a “feature” branch for a change you want to make to the implementation. The interface change would have been made on the **develop** branch using Postman’s real-time collaboration capabilities.
2. Update your code in an IDE. Postman can be used during development to [debug individual endpoints](https://learning.postman.com/docs/sending-requests/troubleshooting-api-requests/).
3. Use Postman to switch to the relevant branch and update the test collections as required.  
 ![](https://blog.postman.com/wp-content/uploads/2021/11/api-feature-test.gif)
4. You can use Postman’s collection runner to execute tests against the local application.
5. Commit and push the source code and the updated collection to the repository.
6. On the develop branch, you’ll see the CI builds reflect the status for the branch you pushed.  
 ![](https://blog.postman.com/wp-content/uploads/2021/11/Screenshot-2021-11-19-at-2.51.33-PM-1024x317.png)
7. Once implementation is complete and the pull request is merged, the develop branch will have the code and updated test collections.

We’re working to add support for other CI providers as well, and we’d love to know what your API-first testing workflow looks like and how Postman can help. Reach out with a comment below. You can also give product feedback through our [Community forum](https://community.postman.com/ "https://community.postman.com/") and [GitHub repository](https://github.com/postmanlabs/postman-app-support/issues "https://github.com/postmanlabs/postman-app-support/issues").

[**Try Postman now**](https://www.postman.com/downloads/ "https://www.postman.com/downloads/")

<button type="button" aria-label="Like Button" data-ulike-id="14355" data-ulike-nonce="edbc8c7a00" data-ulike-type="post" data-ulike-template="wpulike-heart" data-ulike-display-likers="" data-ulike-likers-style="popover"></button>

The post [The Reimagined API-First Workflow, Part 2: for Testers](https://blog.postman.com/the-reimagined-api-first-workflow-for-testers/) appeared first on the [Postman Blog](https://blog.postman.com).