learn API testing as simple as this!

Millan K
5 min readAug 10, 2020

Image showing coding icon between two persons
Credits : Katerina Limpitsouni

TL;DR

Do you use the word buzz `API` a lot, may be you are a recruiter and helping to hire someone with API testing experience, but don’t get it.

or you are a manual tester, finally rolled up your sleeves to make an entry to test automation?. Well then let’s start this super quick crash course.

With all the steps and code I shall share here, I am confident that by the end of this article, if you have never done, you would achieve your: First Test Automation !

Github code (octacat) communicating to API (orange gear icon)
GitHub code (octacat) communicating to API (orange gear icon)

I just need these 3 things form you:

  • Positive attitude, with high spirits speak this aloud (or in your mind)
    I am going to finish this article with my first test automation and then peacefully have a sound sleep tonight.”
    ….
    this was very important, if it is your first time learning test automation.
  • Focus : I want your complete focus for just few minutes and. It is completely okay if you are not a coding expert or a developer.
  • Internet : To stay connected with this article and machine and a computer. ( if you are reading on your smart phone or tablet, feel free to read the article and run it when you get time)

[OPTIONAL] Having a github account will make your experience great, but if don’t have one, you can still proceed.

Remember , if at any point of time if this gets overwhelming to you, jump straight forward to Step 2: THEORY

We will cover this article in 2 parts :

1. Practical : Run the automation test first.
2. Theory : Learn and understand what we did in first step.

Step1: PRACTICAL

Open : cmd (command prompt) or terminal app and run below command to download sample code.

git clone https://github.com/eaccmk/API-newman-POC.git
cd
API-newman-POC

or if you don’t have any idea on what github is, just go to this website :

Download the code as displayed in image by clicking Download ZIP. Once downloaded , go to the download location and unzip it using your favourite unzipping tool !

A screenshot from github.com, showing how to download this project code

Now that you have the code, you might have guessed it to be some kind of API Test Automation. Yes it is !

Let us Run this API automation test….

emoji / image of a running person.

If you have used github and understand the README.md. By now you must have already : understood , ran and learnt your first API test Automation.

  • I would congratulate you and ask you to stop reading this article right away. Move on to read more articles on test automation on Medium , no hard feelings.

But if you are on the other side don’t worry, continue reading..

We are going to run a test automation using a command line tool on your windows CMD or Mac/Linux Terminal. 🔲

  • No fancy UI require which means no complex set-up.
  • Easy to start.
  • Quick to get results.

……..that’s how CLI ( command Line Interface) testing works. And is always CI (Continuous Integration) testing friendly.

Here are quick steps to setup test:

  1. NODE.js: Download and install it from official website nodejs.org
  2. newman: This is the tool we will use for API test automation, if you have installed NODE.js in above step, run command to setup newman:
npm install -g newman

Mac user’s may choose above command or using homebrew to install it :

$ brew install newman

That’s it ! You have got all the tools to run this API test automation.

Open cmd or terminal app navigate to the folder where you cloned ( see git clone .... above or simply said, reach the folder where you unzipped the github project on cmd or terminal.

Run this command ( not sure what run means here… don’t worry, just copy paste and hit ENTER ) 😃

newman run api_collection.json -e environment.json -d test_data.csv

👏 CONGRATULATIONS !! 🎉🎉

you just ran your first API Automation test.

For complete details have a look at the here README.md or from the project which you just unzipped.

Photo by Pankaj Patel on Unsplash

Step 2: THEORY

What we did above in theory is

  • “We just ran a TEST API Automation framework” by hitting (a `request`) a URL and check response.

or, other option

  • Hit a URL and pass on some test data with our `request` and get a response, based upon test data.

If we get the expected response. In API language a `200` or`OK`we call it a success.

Just think if you type www.gooogle.com in your browser and it shows the google home page, it was a success response. Something like this.

google.com showing with OK, 200 response.

Something similar we tested in our automation without launching the browser. As our AIM is to test the Web service ( or website for example) not the browser (chrome, IE, safari etc…)

So this was our result

Hope this was helpful for you to explore further and get into more theory.

✅References:

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Millan K
Millan K

Written by Millan K

Quality Engineering Leadership - I write, share using ➡️ #QualityWithMillan , I also write my blog https://QualityWithMillan.github.io

Responses (1)

Write a response

Excellent, simple and easy 👍🏻

1