Tutorial
Learn REST Assured
REST Assured is the most widely used library for testing HTTP APIs in Java. Tests read almost like a description of the request and what should come back, and they run with JUnit like any other Java test, so they fit into the build and CI a Java team already has.
These lessons build a small test project from an empty folder to a suite that logs in, sends bodies, checks schemas and runs in CI. Every test in them was run with Maven against the API at https://api.testingapis.com, and the output shown is the output it produced. You'll need some Java: classes, methods and imports. If you'd rather start without code, the Postman tutorial covers the same ground in a GUI. Some endpoints need a free account; set your key in TESTINGAPIS_KEY and the example project sends it with every request.
Download the example project
rest-assured-examples.zipA Maven project with 23 tests, one class per lesson. Java 21 and Maven 3.9 or later. Unzip and runmvn test.8 lessons3 levelsFree
Beginner
3 lessonsA Maven project that runs, a first test in the given, when, then style, and checks on JSON responses.
- 01Setting up REST Assured with MavenJava, Maven, the four dependencies, and a project that runs its first test.
- 02given, when, then: your first testsHow a REST Assured test reads, what each part does, and what a failure tells you.
- 03Checking JSON with GPath and HamcrestNested fields, lists, find and findAll, the Float trap, and extracting values.
Intermediate
3 lessonsSending bodies, logging in, and shared setup so tests stay short as the suite grows.
- 04Sending bodies and chaining requestsStrings, maps and Java records as JSON, and a create, read, delete chain.
- 05Authentication in REST AssuredBasic, Digest, API keys, bearer tokens, a login that feeds the next request, and OAuth 2.0.
- 06Request and response specificationsOne place for the base URL, keys and logging, and checks every response must pass.
Advanced
2 lessonsSchemas and parameterized tests for broad coverage, and a suite that runs in CI.
REST Assured is an open-source project released under the Apache License 2.0. This tutorial is independent and isn't affiliated with or endorsed by the REST Assured project or its maintainers.