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 OKor201 Createdresponse. - 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=200ensures 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<800fails 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
- JSONPath:
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
containsthe wordWelcome.
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-Typeheadercontainsapplication/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
<2048bytes.
Available Operators
Robonito provides logical operators to make varied and precise comparisons:
| Operator | Description |
|---|---|
= | Exactly equal to |
!= | Not equal to |
> / < | Strictly greater than / less than |
>= / <= | Greater than or equal to / less than or equal to |
contains | Checks if a substring exists within the target |
not contains | Checks if a substring is absent |
is empty | Validates that a field is null or entirely empty |
is not empty | Validates that a field possesses some value |
matches regex | Validates the target against a Regular Expression |
How to Configure an Assertion
- Open the Test Case: Navigate to your API request.
- Access Assertions: Open the Assertions tab.
- Add New: Click the Add Assertion button.
- Configure: Select your desired Assertion Type, choose the appropriate Operator, provide an Expected Value, and (if necessary) specify a JSONPath.
- Save and Execute: Save your test configuration and run the test to see the assertions evaluated in real-time.