REST Assured Tutorial for Java QA (2026 Complete Guide)
Master REST Assured with 20 real examples: GET/POST/PUT/DELETE, JSON schema validation, auth, filters, and the framework layer that makes API tests survive a rewrite.

Last updated 2026-07-20 · 14 min read · By Avinash Kamble, reviewed by Priyanka G.
REST Assured has been the JVM API testing default for a decade because it reads like English. This tutorial takes you from Maven setup to production-grade framework — authentication, schema validation, request specs, and CI wiring — with 20 examples you can lift directly.
Key takeaways
- Maven and Gradle setup with the exact 2026 dependency versions.
- 20 examples: CRUD, auth, headers, JSON schema, XML.
- Given-When-Then DSL and how to keep specs DRY.
- Wiring REST Assured into JUnit 5 and Allure for CI reports.
1. Maven setup
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>5.5.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>json-schema-validator</artifactId>
<version>5.5.0</version>
</dependency>Full setup and language options in the official REST Assured site.
2. The given-when-then DSL
import static io.restassured.RestAssured.*;
import static org.hamcrest.Matchers.*;
given()
.baseUri("https://api.example.com")
.header("Authorization", "Bearer " + token)
.when()
.get("/orders/4211")
.then()
.statusCode(200)
.body("id", equalTo(4211))
.body("items.size()", greaterThan(0))
.time(lessThan(500L));3. Full CRUD examples
// POST
given().contentType("application/json")
.body("{\"sku\":\"ABC\",\"qty\":2}")
.when().post("/orders")
.then().statusCode(201).body("id", notNullValue());
// PUT
given().contentType("application/json").body(updated)
.when().put("/orders/4211")
.then().statusCode(200);
// DELETE
when().delete("/orders/4211").then().statusCode(204);
// GET with query
given().queryParam("status", "shipped")
.when().get("/orders")
.then().body("size()", equalTo(12));4. JSON Schema validation
import static io.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchemaInClasspath;
when().get("/orders/4211")
.then().body(matchesJsonSchemaInClasspath("schemas/order.json"));Ship the schema in src/test/resources/schemas/. Cross-reference our JSON tester for exploring paths interactively.
5. RequestSpecification — keep it DRY
RequestSpecification api = new RequestSpecBuilder()
.setBaseUri("https://api.example.com")
.addHeader("Authorization", "Bearer " + token)
.setContentType("application/json")
.build();
given().spec(api).when().get("/orders/4211").then().statusCode(200);
given().spec(api).when().delete("/orders/4211").then().statusCode(204);6. Wiring into JUnit 5 + Allure
Add allure-rest-assured, register filter(new AllureRestAssured()), and every request appears in the Allure report with headers, body, and timing. Publish the Allure artifact from GitHub Actions. Bridge to your API testing interview prep and the Postman tutorial cluster for cross-tool depth.
Frequently asked questions
1.REST Assured or Karate — which for a new Java team?
2.Does REST Assured support GraphQL?
3.How do I run REST Assured tests in parallel?
4.Can I share a token across tests?
Practice these questions
Rehearse REST, Postman, REST Assured and contract-testing questions with worked examples.
Was this article helpful?
More from REST API Testing
REST fundamentals — verbs, status codes, contracts.
- Experience-Level QA InterviewsAPI Testing Interview Questions for 1 Year Experience (2026 Complete Guide)
- Experience-Level QA InterviewsAPI Testing Interview Questions for 3 Years Experience (2026 Complete Guide)
- Experience-Level QA InterviewsAPI Testing Interview Questions for Senior Level (2026 Complete Guide)
Keep building your QA edge
Pillar guides- Postman TutorialPostman tutorial for testersPostman from zero to CI — collections, scripts, Newman.
- cURL to Code Converterturn any cURL command into ready-to-run test codeConvert any cURL command to Postman, Playwright, Rest Assured, k6, Cypress, Python, and more — free, in-browser.
- JSON / JSONPath / JMESPath Testerbuild API assertions in the browserDual-engine JSONPath + JMESPath tester with assertion builder and Postman/Playwright/Rest Assured export.
- Postman to Code Converterconvert Postman collection to PlaywrightConvert any Postman collection into a full Playwright, Rest Assured, k6, Cypress, Supertest, Python, or Karate test suite — folders, pm.test assertions, and environments preserved.
- API Tester RoleAPI Tester career path and salaryAPI Tester career guide — Postman, REST Assured, contract testing, and pay.
- QA Skills Hubmap out what to learn nextStructured skill tracks — Selenium, Playwright, Cypress, API, JMeter, SQL, Java, Python for testers.
Practice these questions live
Rehearse with an AI QA interviewer that scores your answers in real time.
Continue reading
Related concepts, tools & standards around API Testing
A quick reference of the people, companies, frameworks and technologies most often mentioned alongside API Testing in real QA teams — useful when you're mapping a learning path, preparing for interviews, or scoping a new project.
Join the QA Community
Connect with fellow testers, share job leads, and get career advice.
Stop Reinventing the Wheel. Upgrade Your QA Arsenal.
Take your testing skills from beginner to Lead Engineer. Supercharge your daily workflow with our premium digital resources.
- Ready-to-use testing strategy templates
- Advanced API & UI automation guides
- ⏱️ Save 10+ hours a week on test planning



Discussion
Ask a question, share your experience, or correct us. Be kind — real people are reading.