(English) Testing REST Services with REST Assured

Home » Blog » Software » Enterprise Software » (English) Testing REST Services with REST Assured

Leider ist der Eintrag nur auf Britisches Englisch verfügbar. Der Inhalt wird unten in einer verfügbaren Sprache angezeigt. Klicken Sie auf den Link, um die aktuelle Sprache zu ändern.

RESTful service testing can be unwieldy and difficult to get started with. Providing a REST API implies using a variety of technologies and techniques such as HTTP, JSON, authentication, various payload transfer mechanisms and content types.

This is where a tool that abstracts over these technical details and facilitates their application comes in handy. REST Assured is a high-level DSL for testing REST APIs. It draws upon behaviour-driven development (BDD) and hence makes for readable test descriptions.

A typical acceptance test with REST Assured looks like this:

                header("X-Auth-Token", token).
                body("id", equalTo(1)).
                body("username", equalTo(username));

As you can see REST Assured allows you to define test processes in a BDD given-when-then fashion:

  • Given existing conditions
  • when a certain action is triggered
  • then the outcome should be …

With REST Assured you can handle the various concepts that come with REST and HTTP in a consistent and straightforward manner:

  • headers
  • content types
  • preflight requests (OPTIONS) for checking if a particular request is supported
  • HTTP status codes
  • various types of parameters: Form parameters, query parameters, path parameters
  • request bodies

REST Assured is a useful tool that allows you to write functional tests and acceptance tests ensuring that the APIs exposed by your server comply with the protocol defined for them.

About the author: Bjoern

Leave a Comment

* Die DSGVO-Checkbox ist ein Pflichtfeld.


I agree