Skip to main content

Assertion

tip

Pre-request operations are performed before the request is sent, allowing for custom scripts and database connections. These are commonly used for setting input parameters, printing data, etc.

Post-response operations take place after a request is sent and are typically used for setting variables, performing assertions, and similar tasks. They also support custom scripts and database connections.

If you're not familiar with scripting and cannot write scripts proficiently, you can perform assertion operations through a visual interface. This feature is primarily used for testing and verifying the results of an interface after it has been sent. Currently, it supports direct assertion verification of Response JSON, Response XML, Response Text, Response Header, Response Cookie, Response Code, Response Time, temporary variables, environment variables, and global variables.

Add Assertions

Post-response – Add Assertions

image.png

View the results from here

image.png

Assertions on Response JSON

image.png

Assertions on Response XML

image.png

Assertions on Response Text

image.png

The validation of header and cookie is similar and will not be further elaborated.

image.png

Assertions on Response Status Code

Directly assert on the response status code.

image.png

Assertions on Response Time

Directly assert on the interface's response time.

image.png

Assert on Temporary Variables, Environment Variables, Global Variables

The usage of temporary, environment, and global variables is the same and will not be further elaborated.

Assertions on variables are often used to check if the variable has changed after the interface is sent.

image.png

View variables from here

image.png

Use of Assertion Conditions

When the condition is Eq(equal to), (NEq)not equal to, LT(less than), LTE(less than or equal to), GT(greater than), GTE(greater than or equal to), Contains, NContains(does not contain), you can fill in the comparison value in the input box, and variables can be used, e.g.: {{key}}.

image.png

When the condition is Regex (regular expression matching), you can enter a regular expression in the input box, for example,/[a-z]*\d*/, to match the content with the expected pattern.

image.png

When the condition is In(belongs to the set), NIn(does not belong to the set), split multiple elements by pressing enter

image.png