Assertions
Use ASSERTS to validate responses.
Basic examples
php
--- ASSERTS ---
.status == "ok"
.count > 0
.items | length > 0
.user.email | test("@")Metadata helpers
php
--- ASSERTS ---
@header("x-request-id") != null
@trailer("x-processing-time") != nullType helpers
php
--- ASSERTS ---
@uuid(.user.id, "v4")
@email(.user.email)
@url(.profile.website, "https")
@ip(.client_ip, "v4")
@timestamp(.created_at, "rfc3339")Notes
ASSERTScan be used alone or together withRESPONSE with_asserts=true- For unary tests, prefer either strict
RESPONSEmatching orASSERTS
Preferred style
- Use boolean plugin calls directly:
@has_header("x-id")instead of@has_header("x-id") == true - Use negation for false checks:
!@has_trailer("grpc-status-details-bin") - Use canonical operators:
startsWithandendsWith