Test File Format
Specification of .gctf files for the Rust CLI.
Think of a .gctf file as: target + input + expected outcome.
Minimal Example
php
--- ADDRESS ---
localhost:4770
--- ENDPOINT ---
package.Service/Method
--- REQUEST ---
{
"id": 1
}
--- ASSERTS ---
.id == 1Supported Sections
- Core:
META,ADDRESS,ENDPOINT,REQUEST,RESPONSE,ERROR,ASSERTS - Supporting:
EXTRACT,REQUEST_HEADERS,TLS,PROTO,OPTIONS,BENCH,DATASET
For section details, use Section Reference.
Execution order
- Preamble sections are read first:
ADDRESS,TLS,PROTO,OPTIONS,REQUEST_HEADERS - Request/validation flow is processed in-order for each RPC interaction
- Multiple
REQUEST/RESPONSE/ASSERTSblocks are allowed depending on RPC pattern
Validation Rules
ENDPOINTis required- At least one of
RESPONSE,ERROR, orASSERTSis required RESPONSEandERRORcannot be used together in one fileADDRESSmay be omitted ifGRPCTESTIFY_ADDRESSis setMETAis optional, but only one is allowed and it must be the first sectionBENCHis optional, but only one is allowed and it should be first or immediately afterMETADATASETis optional, but only one is allowed; its fields are used as{{dataset.field}}template variables and it's mutually exclusive withrun --datafor that file
Type annotations
Add :type to field paths or variables in ASSERTS when the schema is unknown:
php
--- ASSERTS ---
.price:number >= 0
.name:string contains "hello"Use $name to reference EXTRACT variables:
php
--- EXTRACT ---
total:number = .price
--- ASSERTS ---
$total >= 0Attributes
Per-section modifiers using #[name(value)] syntax:
php
#[timeout(10)]
#[retry(2)]
--- REQUEST ---
{
"query": "slow search"
}See Attributes for full reference.
RESPONSE Inline Options
Inline options use section-header flags and key=value pairs:
php
--- RESPONSE with_asserts partial tolerance=0.1 unordered_arrays ---
{
"status": "ok"
}Supported options for RESPONSE:
with_assertsorwith_asserts=true|falsepartialorpartial=true|falsetolerance=<number>redact=["field1","field2"]unordered_arraysorunordered_arrays=true|false
ERROR supports:
with_assertsorwith_asserts=true|falsepartialorpartial=true|false
Default ERROR matching is strict for top-level fields (code, message, details). If details is not returned by the server, it can be omitted from expected ERROR.
Quick links by section
- META
- ADDRESS
- ENDPOINT
- REQUEST
- RESPONSE
- ERROR
- ASSERTS
- EXTRACT
- REQUEST_HEADERS
- TLS
- PROTO
- OPTIONS
- BENCH
- DATASET
- Attributes
Related: Assertions, Plugin System.