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.
Solution: Verify API response - Java Tutorial
From the course: Java: Automated API Testing with REST Assured
Solution: Verify API response
(upbeat music) - [Instructor] How'd you do? Let's walk through the solution of verifying the response to this get product request. First, we create a new method. And inside of this method, we declare the endpoint, which is read one. And then we say, given the ID is 18, when we make a get request to this read one endpoint, then we can assert that. And now we want to assert the three parts of the response, starting with the status code, which should be 200, meaning the get request was successful. Next, we want to make sure that the data was returned to us in JSON format. So we verify that the content type header has a value of application JSON. Then the final part of the response is the body. And the challenge was to verify each of its fields. These can be verified in any order, as long as there's an assertion for each one. The ID should be 18. The name should be equal to multivitamins, 90 capsules. And if you use 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)