This library contains a runtime providing the REST-Assured testing suite. REST-Assured is a testing framework that acts as a client for testing REST web services. It allows you to build REST requests declaratively, using a literate programming syntax, then make assertions about the received response. For example:
bogusContentType = "application/this-is-a-bad-content-type+xml"; given() .body ("<content>dummy</content>") .contentType (bogusContentType) .when() .post ("/content") .then() .statusCode (415) .contentType ("application/vnd.errors+xml") .body (not (empty())) .body (hasXPath ("/errors/unrecognized-content-type", null, equalTo (bogusContentType)));
In the above, the statements following "given()" are the pre-conditions that setup the request. The ".when()" section sets the verb and initiates the request. Any of the assertions about the response, those following ".then()", that do not hold will throw an exception.
REST Assured tests may be easily invoked by the NetKernel XUnit facility and can do very complex, compound tests making use of the Groovy or Java syntax.
In the above example, the "hasXPath()" function is part of the Hamcrest matcher library which REST-Assured is designed to work with (also see GitHub). More about using XML namespaces with REST-Assured and Hamcrest in the subsections on XML configuration.
This library is based on the REST-Assured Project. Our grateful thanks to all those who contributed to the project.
Thanks to Mircea Cocosila for the initial suggestion and testing and porting of example unit tests to RESTAssured.