Overview
Assertions are the final step in your test pipeline. After all blocks execute, assertions check if the data in the DataBus matches your expectations.Simple Assertions (Equality)
The simplest form checks for exact equality:- String values must match exactly
- Numbers must match exactly
- Booleans must match exactly
- Null values must match exactly
Operator Assertions
For more complex validation, use operator objects with 20+ powerful operators.Equality Operators
Numeric Comparisons
gt
: Greater thangte
: Greater than or equallt
: Less thanlte
: Less than or equal
String/Array Operations
Pattern Matching
Type Checks
Boolean Checks
Empty Checks
Complete Example
Multiple Operators
You can combine multiple operators on the same field - all must pass:user.age
: Must be between 18 and 100response.message
: Must contain “success” AND start with capital letteruser.email
: Must be valid email format AND not empty AND at least 5 characters
Common Patterns
- HTTP Status
- AI Judge
- Data Validation
- Tool Validation
Assertion Failures
When an assertion fails, you get detailed error messages:Best Practices
Test Both Success and Failure Cases
Test Both Success and Failure Cases
Test successful response:Test error handling:
Use Ranges Instead of Exact Values
Use Ranges Instead of Exact Values
Bad - too specific:Good - allows for variance:
Validate Structure and Content
Validate Structure and Content
Don't Over-Assert
Don't Over-Assert
Bad - too many assertions make tests fragile:Good - test what matters:If any specific detail changes, overly specific tests will break unnecessarily.
Operator Reference
Equality Operators
Operator | Description | Example |
---|---|---|
equals | Value equals expected | { "equals": 200 } |
notEquals | Value does not equal expected | { "notEquals": 404 } |
Numeric Operators
Operator | Description | Example |
---|---|---|
gt | Greater than | { "gt": 10 } |
gte | Greater than or equal to | { "gte": 18 } |
lt | Less than | { "lt": 100 } |
lte | Less than or equal to | { "lte": 200 } |
String/Array Operators
Operator | Description | Example |
---|---|---|
contains | String/array contains value | { "contains": "text" } |
notContains | String/array does not contain value | { "notContains": "error" } |
minLength | String/array length >= value | { "minLength": 1 } |
maxLength | String/array length <= value | { "maxLength": 100 } |
Pattern Operators
Operator | Description | Example |
---|---|---|
matches | String matches regex pattern | { "matches": "^\\d+$" } |
notMatches | String does not match regex | { "notMatches": "^temp-.*" } |
Type Operators
Operator | Description | Example |
---|---|---|
isNull | Value is null | { "isNull": true } |
isNotNull | Value is not null | { "isNotNull": true } |
isDefined | Value is defined (not undefined) | { "isDefined": true } |
isUndefined | Value is undefined | { "isUndefined": true } |
Boolean Operators
Operator | Description | Example |
---|---|---|
isTrue | Value is boolean true | { "isTrue": true } |
isFalse | Value is boolean false | { "isFalse": true } |
Empty Operators
Operator | Description | Example |
---|---|---|
isEmpty | String/array/object is empty | { "isEmpty": true } |
isNotEmpty | String/array/object is not empty | { "isNotEmpty": true } |