课程: Java: Automated API Testing with REST Assured

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Solution: Verify API response

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…

内容