REST Assured

given · when · then

Test REST services in Java the way you would describe them.

REST Assured sends the request and checks the response in one readable chain. JSON and XML paths, status, headers, cookies, authentication and Spring MockMvc, with no HTTP plumbing in your tests.

LottoTest.javatest
when().
        get("/lotto/{id}", 5).
then().
        statusCode(200).
        body("lotto.lottoId", equalTo(5),
             "lotto.winners.winnerId", hasItems(23, 54));
GET /lotto/5200 OK
{
  "lotto": {
    "lottoId": 5,  ✓
    "winning-numbers": [2, 45, 34, 23, 7, 5, 3],
    "winners": [
      { "winnerId": 23, "numbers": [2, 45, 34, 23, 3, 5] },  ✓
      { "winnerId": 54, "numbers": [52, 3, 12, 11, 18, 22] }  ✓
    ]
  }
}

Add it to your build

Pick what your tests do and copy the dependencies. The BOM keeps every REST Assured module on the same version.

Which module do I need explains each one.

  1. REST Assured 7.0.0-RC1

    It's the release candidate for 7.0.0, a new major release. REST Assured now sends requests with the JDK's HTTP client by default, with Apache HttpClient 5 in the new http-client-apache5 module, and no longer depends on Groovy.

  2. REST Assured 6.3.0

    It prepares for REST Assured 7.0.0, which drops Apache HttpClient 4 and Groovy from the default dependencies. Every API that 7.0.0 removes now has a replacement, the old ones are deprecated, and the new rest-assured-openrewrite module has a recipe that moves your code over.

  3. REST Assured 6.2.0

    The rest-assured module is now written entirely in Java and no longer depends on Groovy directly. Tests that run in parallel no longer fail because of races in the static configuration, and auth().certificate(..) now sends the client certificate to servers that ask for one (mutual TLS).

Release notes

All releases

Smaller changes are in the change log.

Who

REST Assured is developed and maintained by Johan Haleby with the help of many contributors. Johan started the project at Jayway in December 2010. It is now sponsored by Parkster.

Want to help? Open a pull request or an issue.