邵陽疫情最新消息情況南寧百度推廣seo
文章目錄
- Hurl
- install
- start
- demo
- 功能
- 使用變量
- Capturing values 捕獲值
- Asserts 斷言
- 生成報(bào)告
Hurl
官網(wǎng):https://hurl.dev/
Hurl 是一個(gè)命令行工具,它運(yùn)行以簡(jiǎn)單的純文本格式定義的 HTTP 請(qǐng)求。
它可以發(fā)送請(qǐng)求、捕獲值并評(píng)估對(duì)標(biāo)頭和正文響應(yīng)的查詢
install
- dowload
https://github.com/Orange-OpenSource/hurl/releases - run
hurl --version
start
- 編寫.hurl文件
- Running Tests
hurl [options] [FILE...]
demo
- 創(chuàng)建 basic.hurl文件
GET http://localhost:3000
- 執(zhí)行 basic.hurl
hurl basic.hurl
# test mode
hurl --test basic.hurl
功能
使用變量
--variable
選項(xiàng)
hurl --variable host=127.0.0.1 --variable id=1234 test.hurl
--variables-file
選項(xiàng)
- vars.env文件
host=127.0.0.1
id=1234
hurl --variables-file vars.env test.hurl
- HURL_name=value 環(huán)境變量
export HURL_host=example.net
export HURL_id=1234
hurl test.hurl
- hurl文件中:[Options]
GET https://{{host}}/{{id}}/status
[Options]
variable: host=example.net
variable: id=1234
HTTP 304GET https://{{host}}/health
HTTP 200
Capturing values 捕獲值
從 HTTP 響應(yīng)中提取可選值,并存儲(chǔ)在命名變量
- 語法
[Captures]
my_var: QueryType query
- QueryType
status
header
url
cookie
body
bytes
xpath
jsonpath
regex
variable
duration
certificate - demo
[Captures]
# 狀態(tài)
my_status: status
# 標(biāo)頭
next_url: header "Location"
# url
landing_url: url
# cookie
session-id: cookie "LSID"
# body
my_body: body
# JSONPath
contact-id: jsonpath "$['id']"
Asserts 斷言
[Asserts]