Advanced Response Validation in Scriptless Test Automation

There are many tools out there which offer Scriptless Test Automation, and I am pretty sure that they offer some great features and functionalities that one can benefit from. The only issue is that the lack of simplicity in the API testing tool, itself, makes the usage so tiresome, that it will almost equal the efforts that are required in scripted test automation.

This article is the first of a series of articles under the topic, “Advanced Response Validation Tutorial”. This series of API testing articles is to demonstrate how you can validate your API responses using vREST NG, in a very advanced way. The series will contain all the basics that you need to understand in order to perform Advanced Response Validation using vREST NG.

What does vREST NG provide?

vREST NG provides you with Assertions (similar to Test Oracles in other tools/frameworks). These data driven testing assertions are nothing but conditions that you can apply to your test case, which will determine the success or failure of your test case, once you run it. The best part of the data driven testing is that these assertions are Scriptless. This means that the hassle of writing test scripts is diminished.

vrest-assertion

These automated testing assertions consist of another unit, known as Response Validators. Now, as the name suggests, Response Validators are used to validate the automated API testing Response in certain ways. Response Validators in vREST NG allows you to apply comparative conditions at very specific locations in your API Response (but we will talk about that in another blog post).

Let’s see what you can achieve with these Scriptless assertions and Response Validators…

Scriptless Assertions & Response Validators

vREST NG’s assertions and response validators allow you to validate various response attributes for automated testing like,

vrest-assertion

Example of vREST NG Assertions

Status Code

The most basic assertion that judges, if the automated API testing test case will pass or fail, is the Status Code assertion. You can see in the above data testing screenshot, how you can apply a Status Code assertion.

It provides 6 operators to apply as conditions:

Response Time

response-time

This assertion allows you to set certain conditions on Response Time(ms) of your test case.

It also provides 6 operators to apply as conditions:

JSON Body

json-body

JSON Body assertion allows you to apply specific assertions on any part of a json response in the scriptless test automation. In this assertion you have to provide the property to track the json element. For eg, user.username

It provides 18 operators to apply as conditions:

XML Body

XML Body assertion allows you to apply specific assertions on any part of a XML response. In this assertion you have to provide the property to track the XML element. For eg, user/username

It provides 18 operators to apply as conditions:

Text Body (Other types)

text-body

If your assertions are of any different type, then you can apply the Text Body assertion.

It provides 17 operators to apply as conditions:

Conclusion

What you have seen above is just a glimpse of automation testing tutorial in theory. Once you start using vREST NG and scriptless automation tool, you will realize that you don’t actually need to write code most of the time. After writing either one or two vREST NG Test Cases, you will get the hold of it, you will see a great change in your Testing Efforts.