From the course: Java: Automated API Testing with REST Assured
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Accessing response body - Java Tutorial
From the course: Java: Automated API Testing with REST Assured
Accessing response body
- [Instructor] In addition to the status code, a response also contains a body. The response's body contains the data that was requested. So it's extremely important to test this to make sure it's correct. Let's print out the body in its current state for the read one endpoint. First, let's go ahead and comment out the assertion. And instead, we're going to say, log the body. Now, we can run this, and the body will print to the console. Perfect. As we can see, several fields, as well as their values, were returned to us. We have the ID, the name, the description, the price, the category ID and the category name. But before automating the assertions for a test, it's extremely important to manually verify what's the expected result. What if one of these fields is not supposed to be here? Or what if a field that is supposed to be here is missing? We need to catch those types of things now, before we automate the…
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
-
-
-
-
-
(Locked)
Anatomy of a response2m 1s
-
(Locked)
Verifying status code of a response2m 20s
-
(Locked)
Accessing response body1m 35s
-
(Locked)
Verifying fields of response5m 50s
-
(Locked)
Verifying complex response bodies7m 37s
-
(Locked)
Verifying response header2m 52s
-
(Locked)
Deserializing response body7m 54s
-
(Locked)
Challenge: Verify API response33s
-
(Locked)
Solution: Verify API response1m 55s
-
(Locked)