A new framework to test JSON APIs

A new framework to test JSON APIs

author By Nilanjana Apr 15, 2015
Submit guest post

QA at Srijan is exciting. There’s a lot to explore, freedom to implement and the taste of winning. It is awesome.

So far, API testing has involved manual efforts. Now, Srijan has come up with a completely different approach to test APIs by automating JSON API responses. But before jumping to how we did this, let’s backtrack a bit.

We came across a situation where we were required to do automaton of API testing. And we were wondering how to do it. Who would help us out? What would be the outcome? Would we be able to deliver the requirements? It didn't look terribly positive.

We started digging into it, discussed it for a few days, explored topics online, and exchanged ideas with peers within and outside the organization.

So, what was the outcome? We started drawing workflow diagrams on paper to kickstart this. We divided this problem statement into small chunks and started working step by step. This led us to the development of a framework that would help us do the required automation.

What have we achieved with our automation framework?

With this framework, we can

  1. Create content using APIs and verify it

  2. Create content using the UI (webdriver) and verify its response

  3. Capture the search API’s responses

We have more goals planned whose framework is still work in progress.

How did we achieve this?

We divided our framework into various sub-modules which can interact with each other. This block diagram will help you understand the modules of the framework and the workflow as well.                  




This block works in parallel with the Java classes and maintains the sequence of capturing inputs from Excel. It also captures the JSON response, which is the API response. This was introduced so we could use the framework to its maximum extent with the least bit of coding.


This includes the input for different variables to create content. It also serves the purpose of extracting expected results which will be compared with the JSON response later.

JSON Response:

We get different JSON responses after performing some actions. For example, create content using “create APIs”, search content using search APIs, the API’s response of contents created by UI, etc.

Java Classes: This serves the following purposes:

  1. Take input from Excel and process it

  2. Create the content and generate a JSON response

  3. Take the expected results from Excel and the actual results from the JSON response

  4. Processes Step "c", compares it and gives the outcome in form of Pass/Fail

Other features added to this framework:

  1. Clubbing of various JSON Objects or Excel variables to get single value responses. A user can also add separators in between the two key/field values to join fields on her own

  2. Deep digging into JSONs to get values for various keys

  3. Custom Authenticators that are required for creation of content

  4. Handling response from JSON Arrays

In the next blog, we will go deeper into the functionalities with some examples.


Write to us

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms Of Service apply. By submitting this form, you agree to our Privacy Policy.

See how our uniquely collaborative work style, can help you redesign your business.

Contact us