WARNING: This server provides a static reference view of the NetKernel documentation. Links to dynamic content do not work. For the best experience we recommend you install NetKernel and view the documentation in the live system .

REST-Assured

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.

Usage Guide

REST-Assured is an open source project hosted both on Google Code and GitHub. There is also a full User Guide.

Acknowledgements

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.

The configuration resources and documentation were added by Ron Hitchens of OverStory LLP.