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 - Java Tutorial
From the course: Java: Automated API Testing with REST Assured
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
Anatomy of a response2m 1s
-
Verifying status code of a response2m 20s
-
Accessing response body1m 35s
-
Verifying fields of response5m 50s
-
Verifying complex response bodies7m 37s
-
Verifying response header2m 52s
-
Deserializing response body7m 54s
-
Challenge: Verify API response33s
-
Solution: Verify API response1m 55s
-