Assertion Types in Robonito

Assertions are the backbone of automated API testing. They programmatically validate API responses, ensuring that your endpoints behave correctly, reliably, and within acceptable performance thresholds.

In Robonito, you can quickly configure assertions without writing code to verify:

  • HTTP Status Codes: E.g., Verifying a 200 OK or 201 Created response.
  • Response Time: E.g., Ensuring the API responds in under 500ms.
  • Response Body: E.g., Validating specific JSON values or text strings.
  • Response Headers: E.g., Checking for a valid Content-Type.
  • Response Size: E.g., Validating that payloads remain lightweight.

If any assertion fails, the entire test is flagged as Failed. If all assertions pass, the test is marked as Passed.


Supported Assertion Types

1. Status Code

Verifies the HTTP status code returned by the server.

  • When to Use: Confirming successful operations (200, 201), client errors (400, 401), or anticipating specific server errors (500).
  • Example: Setting Status Code = 200 ensures a successful fetch.

2. Response Time (ms)

Validates that the API response is served within a strict time limit (in milliseconds).

  • When to Use: Performance monitoring and enforcing Service Level Agreements (SLAs).
  • Example: Setting Response Time < 800 fails the test if it takes too long.

3. Response Body (JSON)

Extracts and validates a specific value inside a JSON payload using standard JSONPath.

  • When to Use: Verifying user IDs, transaction statuses, or validating nested objects.
  • Example: For the response {"user": {"role": "admin"}}:
    • JSONPath: $.user.role
    • Operator: =
    • Value: admin

4. Response Body (Text)

Validates raw, plain text responses.

  • When to Use: Checking HTML responses, raw text streams, or hardcoded error messages.
  • Example: Searching if the text contains the word Welcome.

5. Response Header

Validates the presence and exact value of an HTTP header returned by the server.

  • When to Use: Confirming correct caching mechanisms, security policies, or response content types.
  • Example: Validating that the Content-Type header contains application/json.

6. Response Size (Bytes)

Validates the overall byte size of the response payload.

  • When to Use: Preventing massive data dumps that could hamper client performance.
  • Example: Ensuring the response size is < 2048 bytes.

Available Operators

Robonito provides logical operators to make varied and precise comparisons:

OperatorDescription
=Exactly equal to
!=Not equal to
> / <Strictly greater than / less than
>= / <=Greater than or equal to / less than or equal to
containsChecks if a substring exists within the target
not containsChecks if a substring is absent
is emptyValidates that a field is null or entirely empty
is not emptyValidates that a field possesses some value
matches regexValidates the target against a Regular Expression

How to Configure an Assertion

  1. Open the Test Case: Navigate to your API request.
  2. Access Assertions: Open the Assertions tab.
  3. Add New: Click the Add Assertion button.
  4. Configure: Select your desired Assertion Type, choose the appropriate Operator, provide an Expected Value, and (if necessary) specify a JSONPath.
  5. Save and Execute: Save your test configuration and run the test to see the assertions evaluated in real-time.