In ACCELQ, robust API testing relies on verifying the response received from a server after making a request. A thorough verification ensures that the API is functioning correctly. This process typically involves checking three core components of the response: the Status Code, the Headers, and the Response Body.
ACCELQ provides a powerful and intuitive interface for setting up these verifications, as well as specific commands for programmatic assertions within your test logic.
The Response Verification Interface
When you add a verification step for an API call, ACCELQ presents a unified "Response verification" window. This interface allows you to interactively build your assertions by clicking on the relevant parts of the received response.
1. Verifying the Status Code
The status code is the first indicator of whether your API request was successful.
- How to do it: Navigate to the Status tab. ACCELQ will display the status code returned by the last test run.
- Adding a Verification: Simply click on the "Status Code" row. A "Verify Status" dialog will appear, pre-filled with the current value. You can confirm this value or enter the expected status code (e.g.,
200for success,201for created,404for not found).
2. Verifying Headers
Headers contain important metadata about the response, such as the content type, server information, and date.
- How to do it: Select the Headers tab. This will list all the headers returned in the API response.
- Adding a Verification: Hover over the header you wish to verify and click on its value. In the "Verify Header" dialog, you can assert that the header's value matches the expected value exactly. For example, you can verify that the
content-typeisapplication/json.
3. Verifying the Response Body
The response body contains the actual data payload, which is often in JSON format. ACCELQ makes it easy to parse this data and verify its contents.
- How to do it: Go to the Response tab. ACCELQ displays a navigable tree view of the JSON response. You can expand and collapse objects and arrays to inspect the data.
- Adding a Verification: To verify a specific piece of data, click on the desired JSON node or its value.
- A "Verify Content" dialog will open.
- ACCELQ automatically generates the
JSONPathto that element. - You can choose the verification type (e.g., equals, contains, is not null).
- Enter the expected value and save the verification.
Using Explicit Verification Commands
For more dynamic scenarios or for building test logic programmatically in the Action editor, ACCELQ provides a suite of specific verification commands. These commands offer fine-grained control over your assertions.
Here are some of the key commands and their purposes:
- Status Code Verification:
Verify ReST Response Status Code: Checks if the response status code matches a given value.
- Header Verification:
Verify Header From ReST Response: Checks if a specific header has an expected value.Is Header exists in ReST Response: Checks for the presence of a header, regardless of its value.
- JSON Body Verification:
Verify JSON Node value matches: The most common command to check the value of a specific element using itsJSONPath.Verify JSON Node exists: Checks if a JSON node is present in the response.Verify JSON Array size Is: Checks the number of elements in a JSON array.Compare two JSON contents: Performs a deep comparison between two JSON objects or strings.
Comments
0 comments
Please sign in to leave a comment.