Creating A Simple API Testing Suite Using Newman/Github Actions

Berkay Kırmızıoğlu
3 min readJul 21, 2022

There are so many options for API Tests. Generally, testers and developers use Postman very actively to manage API Requests. Likewise, Jenkins and GitLab are used a lot to manage API Test pipelines.

I’ve been seeing testers struggling with API tests. That’s why I just wanted to write this basic article. In this article, I will talk about how you can create API Test automation in a very simple way.

Before Starting; complete example in my Github Repository

First of all let’s import these cURLs into Postman as a raw text and you can write your assertions however you want. My examples are;

Current Weather Data — Latitude/Longitude

curl — location — request GET ‘https://api.weatherbit.io/v2.0/current?lat=52.5200&lon=13.4050&key=201c3c5c2259496286c0e2d4894ddc3a' \
— header ‘Accept: application/json’

Current Weather Data — By City Id

curl — location — request GET ‘https://api.weatherbit.io/v2.0/current?city_id=2950159&key=201c3c5c2259496286c0e2d4894ddc3a' \
— header ‘Accept: application/json’

Then let’s write our Github Actions yaml file

What happening up there?

  1. This job will be triggered automatically when the a code pushed.

2. We are installing the NPM packages related to Newman so that we can run the Newman commands successfully on our Ubuntu machine.

3. Then we create a folder in run time where we can write the test results.

4. Then our tests are running in the collection with the Newman command, from which we installed the NPM packages.

5. As a last step, as you can see in a moment, we are uploading the artifacts so you can download the test results.

Let’s go to Actions tab in our Github Repo

As you can see here, an artifact has created as API Test Reports. When you download this artifact.

A test report will be generated as follows.

Happy API Testing!

--

--