邵阳疫情最新消息情况青岛seo计费
文章目录
- Hurl
- install
- start
- demo
- 功能
- 使用变量
- Capturing values 捕获值
- Asserts 断言
- 生成报告
Hurl
官网:https://hurl.dev/
Hurl 是一个命令行工具,它运行以简单的纯文本格式定义的 HTTP 请求。
它可以发送请求、捕获值并评估对标头和正文响应的查询
install
- dowload
https://github.com/Orange-OpenSource/hurl/releases - run
hurl --version
start
- 编写.hurl文件
- Running Tests
hurl [options] [FILE...]
demo
- 创建 basic.hurl文件
GET http://localhost:3000
- 执行 basic.hurl
hurl basic.hurl
# test mode
hurl --test basic.hurl
功能
使用变量
--variable
选项
hurl --variable host=127.0.0.1 --variable id=1234 test.hurl
--variables-file
选项
- vars.env文件
host=127.0.0.1
id=1234
hurl --variables-file vars.env test.hurl
- HURL_name=value 环境变量
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 响应中提取可选值,并存储在命名变量
- 语法
[Captures]
my_var: QueryType query
- QueryType
status
header
url
cookie
body
bytes
xpath
jsonpath
regex
variable
duration
certificate - demo
[Captures]
# 状态
my_status: status
# 标头
next_url: header "Location"
# url
landing_url: url
# cookie
session-id: cookie "LSID"
# body
my_body: body
# JSONPath
contact-id: jsonpath "$['id']"
Asserts 断言
[Asserts]