Test Automation for the REST API

With the REST architecture taking over the old MVC patterns, most API started using just one way to communicate with HTTP. Suddenly the business logic and any kind of data processing was done at the server and the client side was only responsible for representation of data and basic manipulations.

Testing of the REST API layer can be done using the REST-assured library that was developed by jay-way company. RESTful APIs generally are of two types: one returning XML responses and one returning JSON response. The assured - lib supports POST, GET, PUT, DELETE, OPTIONS, PATCH and HEAD requests and can be used to validate and verify the response of these requests.

You can add a flavor of BDD by using tools like cucumber or specflow:

When /^I send a GET request for "([^\"]*)"$/ do |path|
  get path

When /^I send a POST request to "([^\"]*)" with the following:$/ do |path, body|
  post path, body

When /^I send a PUT request to "([^\"]*)" with the following:$/ do |path, body|
  put path, body

When /^I send a DELETE request to "([^\"]*)"$/ do |path|
  delete path

Then /^the response should be "([^\"]*)"$/ do |status|
  last_response.status.should == status.to_i

Then /^the response JSON should be:$/ do |body|
  JSON.parse(last_response.body).should == JSON.parse(body)


  1. Test Automation for the REST API Thanlku for sharing about this...
    Best SEO training in hyderabad,training by professional experts during experience more than 15 years,and Giving placement in their company.And giving knowledge of All digital marketing modules with professional practise.Train by expert and Earn huge money per month.Best SEO training in hyderabad

  2. Thanks for the info! Can you please suggest tools for API testing automation?


Post a Comment

Popular posts from this blog

XPATH for IE / internet explorer

RPA - Blue Prism, OpenSpan, Automation Anywhere vs UIPath