๐งช REST Assured
Learn REST Assured for Java API automation with request chaining, assertions, serialization, authentication and CI-ready test design.
REST Assured is a DSL library for writing REST API tests in Java. With given().when().then() syntax, POJO support, JSON Schema validation, and CI/CD integration, it has become the industry standard in enterprise API testing.
What you can learn on this page
- ๐ Why REST Assured? โ Deployment is at 9 AM. The developer said "API is ready." You manually tested 47 requests in Postman โ 3 hours gone. Next deployment, same story. REST Assured cuts those 3 hours down to 30 seconds. ๐ฌ Real Scenario: Moving from Postman to REST Assure
- โ๏ธ Setup & Project Structure โ Every building starts with a foundation. In a REST Assured project the foundation is: pom.xml dependencies + BaseTest class. Get these right and writing the actual tests becomes easy. Maven pom.xml โ All Dependencies
- ๐ก Basic HTTP Requests (using reqres.in) โ All examples use the free test API reqres.in. To switch to your real project's API, just change the baseUri and endpoint path. given/when/then โ REST Assured Chain Live
- ๐ Authentication โ You cannot enter a building without showing ID to the doorman. In an API, that ID is either Basic Auth (username:password), a Bearer Token (JWT), or an API Key. REST Assured supports all three. Basic Authentication
- ๐ฆ POJO & Jackson โ Type-Safe API Testing โ Writing raw String JSON is like sending a message in code โ a typo gives no compile error, it just blows up at runtime. Using a POJO means the IDE warns you, autocomplete works, and you get full type safety. What is a POJO? โ Java Analogy
- โ Assertions โ Hamcrest Deep Dive โ An assertion asks: "I expected this, I got that โ do they match?" Hamcrest matchers turn that question into code AND clearly tell you what went wrong when a test fails. All Important Hamcrest Matchers
- ๐๏ธ JSON Path & Schema Validation โ "data.users[0].address.city" โ JSON Path is like a street address to the value you want inside nested JSON. Instead of latitude/longitude, you use dots and square brackets. extract() โ Pulling Values from a Response
- ๐ Test Chaining โ Real E2E Scenarios โ In real life, API tests are not independent of each other. First register, then login, then add to cart, then pay. The output of each step is the input of the next. Full E2E CRUD Chain (reqres.in)