Verification Snippets in Katalon Studio
Katalon Studio supports the ability to write verification scripts directly in the details of the web service object. The Verification Snippets reduces the time of going back and forth between the test case and the request object to add test scripts. Verifying the response can be done instantaneously.
To access the Verification snippets, click on the Verification tab of the web service request object.
Using Verification Snippets
When you click on one of the available snippets, Katalon Studio automatically generates a snippet for you.
- The generated snippet is only an example. You should not try to use them immediately without making adjustments to match your needs.
You can also verify the data of the XML or JSON response body. To add these verification scripts, in the Response panel, switch to JSON or XML response body, select the data, and press key combination Ctrl / Command + K.
Katalon Studio compares the values in the response body with the predefined values in verification scripts.
Once the verification snippets are generated, you can use them in either your current web service request object or in your test case.
In the web service request object, click on the drop-down of Test Request and select Test Request and Verify.
This action sends the current request and also executes verification snippets. Verification logs executed using verification snippets are displayed on the Verification Log tab. If you do not want to send a test request using current verification snippets, then just click on Test Request.
In a test case, use the
WS.sendRequestAndVerify
keyword. This keyword also sends the current request and executes verification snippets. For example:WS.sendRequestAndVerify(findTestObject('Your_Test_Object'))
The execution results are displayed in the Log Viewer tab.
List of Available Verification Snippets
On the right panel of the Verification tab is the list of common pre-built snippets which can assist you in most of the verification cases.
Snippet | Description |
---|---|
Get current response | Return response object after sending a request successfully. |
Get current request | Return the current request object. |
Get a global variable | Return the value of a global variable. |
Get a variable | Return the value of a variable that you have created in the Web Service Test Object. |
Response body: Contains string | Verify if a response body contains a specific string. |
Response body: Convert to JSON Object | Convert a response body to JSON. |
Response body: Is equal to a String | Verify if a response body is equal to s string. |
Response body: JSON value check | Check for a JSON value in a response body. |
Response headers: Content-Type header | Verify Content-Type header's value. |
Status code: Code is 200 | Verify if response's status code is 200 or no. |
Status code: Successfully request | Verify if the request is sent successfully. |
Request body: Validate GraphQL against schema | Validate the request body against a GraphQL schema. |
Response body: Array contains | Verify specified arrays contain values. |
Response body: Validate JSON against schema | Validate the response body against a JSON schema. |
Response body: Validate XML against schema | Validate the response body against an XML schema. |