Skip to content
Ameen Abozaid
Planned lessonJNR-046-L02

REST Assured

  • Lesson 2 of 5
  • Junior
On This Lesson 4 topics

This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.

In this lesson

write readable HTTP tests.

Planned topics

  • REST Assured uses given / when / then to send requests and check responses. Verify the current version before recording.
  • Set the port from @LocalServerPort.
  • Check status, headers, and body fields with JSON paths: body("items.size()", is(2)).
  • extract().path(...) pulls a value for the next step (for example a token or id).
  • Check body fields that matter, not the whole JSON string.
Draft outline details

Demonstration

java
given().port(port).contentType(JSON).body(newOrder)
.when().post("/api/orders")
.then().statusCode(201)
    .header("Location", containsString("/api/orders/"))
    .body("status", equalTo("NEW"));

Check your understanding

Why not compare the entire JSON string?

Show answer

It breaks on harmless changes such as field order or new fields.

Practice

Apply this lesson with the module's lab, exercises and quiz.

Lab and exercises Quiz

Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.

Continue to next lesson

Type to search levels, phases, modules and lessons.