Back to Course
Rest Assured

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.

Ready to master real-world software testing?

Learn manual and automation testing hands-on with mentor-led sessions.

Explore Course