Applying Hamcrest Assertions On Response Validations Using Restassured
What is Hamcrest?
Hamcrest is a library of readable "matchers" (like equalTo, containsString, greaterThan) used to write flexible, expressive assertions.
Examples
.body("data.id", equalTo(2))
.body("data.email", containsString("@reqres.in"))
.body("data.id", greaterThan(0))
.body("support.text", not(isEmptyString()));
Why Testers Use Hamcrest
Hamcrest matchers make assertions read almost like natural language, and support far more nuanced checks than simple equality — such as ranges, patterns, and collection contents.
PreviousExtracting Token From Login Request & Supplying In Following Requests Using Restassured
Next Verifying Response Json Schema Using Restassured
Ready to master real-world software testing?
Learn manual and automation testing hands-on with mentor-led sessions.
.png)