We are moving to a service oriented architecture at work based using technology from Apigee which is helping us build securable and scalable APIs for our applications to use.
One of the challenges is testing these APIs. Being a Java shop, sending the HTTP requests can be a bit of a faff, as can parsing the resultant JSON responses. We want the tests to be automated, and seeing as we use Junit and Hamcrest something that works in a similar way would be good. After a bit of googling, one of my colleagues pointed me in the direction of Rest-Assured.
Rest-Assured is a domain specific language for the easy testing of REST services, and attempts to bring the simplicity of using a dynamic language such a Ruby or Groovy to Java. It does this pretty well!
What I particularly like is that you can set up a fairly complex scenario with a minimum of code and it is really easy to see what is being tested. The documentation on the website is really good, but as an example:
Assume that a GET request to http://localhost:8080/ returns JSON as:
1 2 3 4 5 6 7 8 9 10 11 12 13
Verifies that the lottoId is 5 when you get it. It’s easy to read, simple to setup, and really powerful…