From the course: Java: Automated API Testing with REST Assured

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Verifying complex response bodies

Verifying complex response bodies - Java Tutorial

From the course: Java: Automated API Testing with REST Assured

Start my 1-month free trial

Verifying complex response bodies

- [Instructor] The response we verified in the last section contained a single object. However, many times responses are more complex and can include multiple reason objects. And sometimes these are even nested. Let's look into how to verify complex response bodies like these. If we make a call to the read product end point which will return all of the products in our application, we'll see the body is an object that contains an array called records. And inside of this array we have multiple objects which contain multiple fields. So how do we verify this? One thing we may want to ensure is that the products are actually returned. There are 19 products here. So let's do a little bit of verification. We can start off by first verifying the status code. So we'll say assert that and we'll say, we want to assert that the status code is 200. Okay? Now, let's get into asserting the body. But again, we're not going to…

Contents