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.

Verifying status code of a response

Verifying status code of a response - Java Tutorial

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

Start my 1-month free trial

Verifying status code of a response

- [Instructor] Status codes, which are returned as part of a response of the first indicator of the success of a request. It's important to know what the expected status code should be for a given request. This is often specified in the documentation for the API. For example, for the request to get a product, we expect to receive a 200 status code, which indicates that the request was successful. Let's verify this using rest assured. Here, we are revisiting our get product test. We made this get request by saying, given the ID is two when we make a get request to this read one endpoint, then we receive a response. While this executes the request and captures the response, that doesn't verify anything. We can complete the verification by using a method within rest assured called assert that. So as opposed to storing this in this response variable, and logging it out, instead, we can append the assert that method right after…

Contents