斷言與擷取
概觀
HTTP / FastHttp task 可附 assertions 與 extract,會在 Locust 的 catch_response 之下執行。失敗的斷言會被 Locust 標為 failure,並出現在所有報告中。
斷言
|
行為 |
|---|---|
|
|
|
|
|
|
|
沿著 |
|
|
範例
{
"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"}
]
}
擷取
|
來源 |
|---|---|
|
與 |
|
|
|
|
擷取值會以指定 var 名寫入參數解析器;後續 task 以 ${var.NAME} 引用。