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

Accessing response body - Java Tutorial

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

Start my 1-month free trial

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…

Contents