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
Create content using APIs and verify it
Create content using the UI (webdriver) and verify its response
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.
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:
Take input from Excel and process it
Create the content and generate a JSON response
Take the expected results from Excel and the actual results from the JSON response
Processes Step "c", compares it and gives the outcome in form of Pass/Fail
Other features added to this framework:
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
Deep digging into JSONs to get values for various keys
Custom Authenticators that are required for creation of content
Handling response from JSON Arrays
In the next blog, we will go deeper into the functionalities with some examples.