REST api testing made easy .
I am constantly involved in developing backend services for team and
worked on simple framework to test the services. Here is thought behind the framework .
Usual Check is HTTP Status =200 . Also usually part of JSON response is used to validate
eg "status":"OK" . Framework adapts to these conditions and would validate the response for all request . More test can be easily added on top of base validation
Base URL and the HTTP Headers to be setup can be setup once
and can be reused for all the tests .
payload for POST and PUT are usually JSON and this can be easily setup as templates
This is the one from my example
{
"firstName":"{{firstName}}",
"lastName":"{{lastName}}",
"phone":"{{phone}}",
"email":"{{email}}"
}
Data for the template can be driven from JSON.
Framework converts JSON -> Java Object and Object is used to populate the template .
Example of JSON data to populate the above template
{
"firstName":"Arun",
"lastName":"Selvamami",
"phone":"000-000-000",
"email":"arun2dot0@gmail.com"
}
and changing the Base url
framework is powered by RestAssured , hamcrest and mustache
Check out the code at https://github.com/arun2dot0/TestRest
I am constantly involved in developing backend services for team and
worked on simple framework to test the services. Here is thought behind the framework .
Http Responses Validation
Services provide a response to indicate if the request was successful .Usual Check is HTTP Status =200 . Also usually part of JSON response is used to validate
eg "status":"OK" . Framework adapts to these conditions and would validate the response for all request . More test can be easily added on top of base validation
Set URL , HTTP Headers once
Base URL and the HTTP Headers to be setup can be setup onceand can be reused for all the tests .
Use Mustache templates to define HTTP Post and Put Payload
payload for POST and PUT are usually JSON and this can be easily setup as templates
This is the one from my example
{
"firstName":"{{firstName}}",
"lastName":"{{lastName}}",
"phone":"{{phone}}",
"email":"{{email}}"
}
Data for the template can be driven from JSON.
Framework converts JSON -> Java Object and Object is used to populate the template .
Example of JSON data to populate the above template
{
"firstName":"Arun",
"lastName":"Selvamami",
"phone":"000-000-000",
"email":"arun2dot0@gmail.com"
}
Easily setup for multiple environments
You can rerun the test for other environments by setting up different dataand changing the Base url
framework is powered by RestAssured , hamcrest and mustache
Check out the code at https://github.com/arun2dot0/TestRest