Apicat Docs
  1. Pre/Post processors
Apicat Docs
  • What is Apicat?
  • Send requests
    • Create requests
      • Request basics
      • Parameters and body
      • Request headers
      • Request settings
      • Dynamic values
      • HTTP/2
      • SOAP/WebService
    • Authentication and authorization
      • Overview
      • CA and client certificates
      • Authorization types supported by Apidog
      • Digest Auth
      • OAuth 1.0
      • OAuth 2.0
      • Hawk Authentication
      • Kerberos
      • NTLM
      • Akamai EdgeGrid
    • Response and cookies
      • Overview
      • API response in Apidog
      • Create and send cookies
      • Debug requests
    • Dynamic values Modules
      • Airline
      • Animal
      • Color
      • Commerce
      • Company
      • Database
      • Datatype
      • Date
      • Finance
      • Food
      • Git
      • Hacker
      • Helpers
      • Image
      • Internet
      • Location
      • Lorem
      • Music
      • Number
      • Person
      • Phone
      • Science
      • String
      • System
      • Vehicle
      • Word
  • Environments & variables
    • Overview
    • Using variables
    • Environments & services
  • Pre/Post processors
    • Overview
    • Assertion
    • Extract variable
    • Wait
    • Database operations
      • Overview
      • MySQL
      • MongoDB
      • Redis
      • Oracle Client
    • Using scripts
      • Overview
      • Pre processor scripts
      • Post processor scripts
      • Public scripts
      • Postman scripts reference
      • Calling other programming languages
      • Using JS libraries
      • Visualizing responses
      • Script examples
        • Assertion scripts
        • Using variables in scripts
        • Using scripts to modify request messages
        • Other examples
  • Best practices
    • How to handle API signatures
    • How to access OAuth 2.0 protected APIs
    • Apidog collaboration workflow
    • Managing authentication state in Apidog
  • Account & preferences
    • Account settings
    • Generate OpenAPI access token
    • Language settings
    • Hot keys
    • Network proxy configuration
    • Data backup
    • Updating Apidog
    • Deleting account
    • Experimental Features
  • References
    • API-Design First Approach
    • Apidog OpenAPI/Swagger Specificaiton Extensions
    • JSONPath
    • XPath
    • Regular Expressions
    • JSON Schema
    • CSV File Format
    • Install Java Environment
    • Runner deployment environment
    • Apidog flavored Markdown
  1. Pre/Post processors

Assertion

Assertions play a crucial role in API testing. When you need to verify if the response of an request meets your expectations, you have to write an assertion. In tools like Postman, assertions require writing scripts manually. Nevertheless, in Apidog, you can visually create assertions, which is extremely convenient.

Adding an assertion to post processor#

1
In the Run tab (Design-first Mode) or the Request tab (Request-first mode), navigate to Post Processors.
Design-first Mode
Request-first Mode
image.png
2
Hover over "Add Post Processor" and select "Assertion".
image.png
3
Select the target for your assertion, which can be various elements in the API response such as headers, body content, or status codes. You can choose the specific element that you want to verify against your expected outcome. (For example:$.data.status) Please note that the root object is represented by$, and it works for both objects and arrays.
image.png
4
If the target is in the JSON body, use JSONPath to extract the desired value.
5
Set the assertion conditions based on your testing requirements. You can define criteria such as equal to, not equal to, contains, does not contain, greater than, less than, etc.
In the assertion value field, you can input a static value or use dynamic variables in the format of {{variable}}.
6
Click on the send button to execute the assertions. You can view the results of the assertions in the right-hand side panel.
image.png
When performing assertions in Apidog, all data is automatically converted to STRING for comparison. While this simplifies the process in most cases, you may encounter bad cases such as 4 not being equal to 4.0. For such specific assertions where data comparison needs to consider more intricate details, you can utilize custom scripts to write assertions manually.

Setting assersions on actual response#

To quickly create an assertion based on the actual response, hover over the response field(e.g., on endpoint response or test reports), and click onassertion.
assertion-on-actual-response.png

Using scripts for assertions#

In Apidog, you can employ the pm.test syntax to create assertions using scripts. Apidog is compatible with Postman scripts, allowing users to leverage existing scripts seamlessly.
Learn more about scripts.
Modified at 2025-06-25 07:57:16
Previous
Overview
Next
Extract variable
Built with