DEV Community

Cover image for Running a Postman Collection in a CI Pipeline
Dennis Whalen for Leading EDJE

Posted on

Running a Postman Collection in a CI Pipeline

Introduction

If you've been involved with application development or testing, you've probably used Postman to test API endpoints. In this post I'm going to create a sample endpoint, write Postman tests for the endpoint, and create a Github workflow to run those Postman tests whenever I push changes to the repo. The code we'll walk through can also be found in my repo.

So let's get started.

The app

The point of this article is to walk through creating Postman tests and getting them running in a pipeline, so I'm not going to spend a lot of time with the sample app. To get an endpoint stood up quickly, I'm using an open source tool called JSON server.

I'll avoid the temptation to tell you all the awesome things that JSON server can do for you. For now, I'll just say I can spin up a fully functional endpoint with just docker and a JSON file.

This endpoint is going to be pretty basic, and will provide basic CRUD operations for a list of albums.

The json file looks like this:

{
    "albums": [
        {
          "id": 1,
          "artist": "The Beatles",
          "title": "Please Please Me",
          "year": "1963"
        },
        {
          "id": 2,
          "artist": "The Beatles",
          "title": "With the Beatles",
          "year": "1963"
        },
        {
          "id": 3,
          "artist": "The Beatles",
          "title": "A Hard Day's Night",
          "year": "1964"
        },
        {
          "id":