← Back to libraryQuestion 230 of 468
🔌REST AssuredBeginner

Setup and Dependencies

📌 Definition:

REST Assured is added as a Maven/Gradle dependency. You typically include rest-assured, the JSON path/schema modules, and a test framework (TestNG or JUnit), plus static imports to enable the DSL.

📖 Detailed Explanation:

In Maven you add io.rest-assured:rest-assured (test scope), often json-schema-validator for schema checks and json-path. For readable code you add static imports: import static io.restassured.RestAssured.*; and import static org.hamcrest.Matchers.*;. You configure a base URI once (RestAssured.baseURI = 'https://api.example.com') so tests use relative paths. A Jackson or Gson dependency on the classpath enables automatic POJO serialization/deserialization. Version alignment matters — mismatched Groovy/Jackson transitive versions are a common setup snag.

🔑 Key Points:
  • Maven dep: io.rest-assured:rest-assured (test scope)
  • Add json-schema-validator / json-path as needed
  • Static imports: RestAssured.* and Hamcrest Matchers.*
  • Jackson/Gson on classpath enables POJO (de)serialization
🌍 Real-World Example:

A pom.xml with rest-assured + testng + jackson-databind lets the team write given().body(userPojo)... and REST Assured auto-serializes the POJO to JSON using Jackson.

🎯 Scenario-Based Interview Question:

A teammate's given() and equalTo() don't compile even though REST Assured is on the classpath. What's missing?