📡 Basic HTTP Requests (using reqres.in)

Basic HTTP Requests (using reqres.in): Writing your first REST Assured test is like tuning a radio receiver: find the right frequency (baseUri + endpoint) and the right protocol

Writing your first REST Assured test is like tuning a radio receiver: find the right frequency (baseUri + endpoint) and the right protocol (HTTP verb + headers) and the response arrives on its own — miss either and it stays silent. You can already send the same request in Postman — so why write it as code? Because every manual Postman click proves it works "right now"; every REST Assured @Test proves it keeps working "every time." In Java you can make HTTP requests with HttpURLConnection or HttpClient, but that needs 15 lines of boilerplate; REST Assured's `given().when().get("/users").then()` chain does the same in 3 lines and lets you attach the assertion directly in that same chain. The practical QA value: the test you write against reqres.in needs only the baseUri changed when you switch to your real project's API — as long as the auth token scheme and request body structure match, the test code is unchanged. That reusability saves you 2–3 hours of adaptation work at the start of every sprint.

given/when/then — REST Assured Chain Live

Press "▶ Run Test": watch the given() → when() → then() chain execute, the request being sent, and assertions running step by step.

GET — Paginated User List

Micro Lab: REST Assured assertion writing

Replace the TODO line with the critical line from the expected solution. This is not a real runtime; the goal is to reinforce writing the correct structure in a controlled way.

How Does queryParam("page", 2) Transform the URL?

The .queryParam("page"…

The `.queryParam("page", 2)` call APPENDS `?page=2` to `GET /api/users` — instead of hand-concatenating the URL string, REST Assured encodes it FOR you.

`.body("data", hasSize(6))` verifies the `data` array has EXACTLY 6 elements — this tests the ASSUMPTION that `reqres.in` returns 6 users per page.

.body("data.first_name"…

`.body("data.first_name", everyItem(notNullValue()))` verifies EVERY SINGLE user in the array has a non-empty `first_name` in one line — no NEED to write 6 separate assertions.

.time(lessThan(5000L)) adds performance…

`.time(lessThan(5000L))` adds performance to the SAME chain — functional correctness AND speed are proven together in one test.