Assertions & Extractors
Overview
HTTP and FastHttp tasks accept assertions and extract blocks
that run under Locust’s catch_response. Failed assertions mark the
request as a Locust failure and surface in every report.
Assertions
|
Behaviour |
|---|---|
|
|
|
|
|
|
|
Resolves |
|
|
Example
{
"method": "get",
"request_url": "${var.base}/health",
"assertions": [
{"type": "status_code", "value": 200},
{"type": "json_path", "path": "status", "value": "ok"},
{"type": "header", "name": "X-Service", "value": "checkout"}
]
}
Extractors
|
Source |
|---|---|
|
Same dotted path syntax as the |
|
|
|
|
Extracted values are written into the parameter resolver under the
chosen var name; subsequent tasks reference them as ${var.NAME}.
{
"method": "post",
"request_url": "${var.base}/login",
"json": {"email": "u@example.com", "password": "secret"},
"extract": [
{"var": "auth_token", "from": "json_path", "path": "data.token"},
{"var": "request_id", "from": "header", "name": "X-Request-Id"}
]
}