In vREST, response validation is done with the help of various assertions and/or response validators.
Here is the video tutorial for the same:
<iframe width="560" height="315" src="https://www.youtube.com/embed/KDbWuqUPnfA?list=PLmua155_WrDyoe7dYDB3lCfh-UK4XicT6?ecver=1" frameborder="0" allowfullscreen></iframe> |
With the help of assertions and response validators, you can validate various response attributes like
The above screenshot gives an idea of how vREST handles response validation. The above assertions validates the following:
In the above image, the last "Text Body" assertion is of prime importance. The last assertion basically calls "Default Validator" (vREST's in-built response validator) to validate your response body. In this case, you need to set the expected response body of the test case in "Expected Body" sub-tab. The default validator is very simple to use and provides you a powerful way to validate your test case responses.
Suppose your test case responds the following JSON response:
{ "key1": "value1", "key2": "value2", "key3": { "key3.1": "value3.1", "key3.2": "value3.2", "key3.3": "value3.3", "key3.4": "value3.4", "key3.5": "value3.5" }, "key4": [ "value1", { "key4.2.1": "value4.2.1", "key4.2.2": "value4.2.2" }, "value3", "value4" ], "key5": "value5", "key6": "value6" } |
And you want to validate the following:
Then you may write your expected body like this:
Note:
For more information on assertions and validators, please follow the links below: