hurl
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseHurl
Hurl
Quick Start
快速开始
Hurl is a command line tool that runs HTTP requests defined in a simple plain text format. It can chain requests, capture values, and evaluate queries on headers and body responses.
shell
$ hurl session.hurl
$ hurl --test *.hurlHurl是一个命令行工具,可运行以简单纯文本格式定义的HTTP请求。它可以链式执行请求、捕获值,并对响应头和响应体执行查询。
shell
$ hurl session.hurl
$ hurl --test *.hurlHurl File Format
Hurl文件格式
Hurl files use extension and consist of one or more HTTP entries. Each entry has a mandatory request and an optional response section.
.hurlhurl
GET https://example.org/api
HTTP 200
Content-Type: application/json
[Asserts]
jsonpath "$.status" == "success"Hurl文件使用扩展名,由一个或多个HTTP条目组成。每个条目包含一个必填的请求部分和一个可选的响应部分。
.hurlhurl
GET https://example.org/api
HTTP 200
Content-Type: application/json
[Asserts]
jsonpath "$.status" == "success"Comments
注释
Comments begin with and continue until the end of line:
#hurl
undefined注释以开头,持续到行尾:
#hurl
undefinedCheck that the API returns the expected response
Check that the API returns the expected response
GET https://example.org/health
HTTP 200
undefinedGET https://example.org/health
HTTP 200
undefinedRequests
请求
Basic Request
基础请求
hurl
GET https://example.org/endpointhurl
GET https://example.org/endpointHTTP Methods
HTTP方法
hurl
GET https://example.org/resource
POST https://example.org/resource
PUT https://example.org/resource
PATCH https://example.org/resource
DELETE https://example.org/resource
HEAD https://example.org/resource
OPTIONS https://example.org/resourcehurl
GET https://example.org/resource
POST https://example.org/resource
PUT https://example.org/resource
PATCH https://example.org/resource
DELETE https://example.org/resource
HEAD https://example.org/resource
OPTIONS https://example.org/resourceHeaders
请求头
hurl
GET https://example.org/api
User-Agent: MyApp/1.0
Accept: application/json
Content-Type: application/jsonhurl
GET https://example.org/api
User-Agent: MyApp/1.0
Accept: application/json
Content-Type: application/jsonQuery Parameters
查询参数
hurl
GET https://example.org/search
[Query]
term: hurl
page: 1
limit: 10hurl
GET https://example.org/search
[Query]
term: hurl
page: 1
limit: 10Form Data
表单数据
hurl
POST https://example.org/login
[Form]
username: user@example.com
password: secret123hurl
POST https://example.org/login
[Form]
username: user@example.com
password: secret123Multipart Form Data
多部分表单数据
hurl
POST https://example.org/upload
[Multipart]
field1: value1
field2: file,data.txt;
field3: file,image.png; image/pnghurl
POST https://example.org/upload
[Multipart]
field1: value1
field2: file,data.txt;
field3: file,image.png; image/pngJSON Body
JSON请求体
hurl
POST https://example.org/api/users
{
"name": "John Doe",
"email": "john@example.com",
"age": 30
}hurl
POST https://example.org/api/users
{
"name": "John Doe",
"email": "john@example.com",
"age": 30
}XML Body
XML请求体
hurl
POST https://example.org/soap-service
Content-Type: application/soap+xml
<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Body>
<GetStatus>
<id>12345</id>
</GetStatus>
</soap:Body>
</soap:Envelope>hurl
POST https://example.org/soap-service
Content-Type: application/soap+xml
<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Body>
<GetStatus>
<id>12345</id>
</GetStatus>
</soap:Body>
</soap:Envelope>GraphQL
GraphQL
hurl
POST https://example.org/graphql
```graphql
query {
user(id: "123") {
name
email
}
}undefinedhurl
POST https://example.org/graphql
```graphql
query {
user(id: "123") {
name
email
}
}undefinedBasic Authentication
基础认证
hurl
GET https://example.org/protected
[BasicAuth]
admin: secretpasswordhurl
GET https://example.org/protected
[BasicAuth]
admin: secretpasswordCookies
Cookie
hurl
GET https://example.org/page
[Cookies]
session: abc123
preference: dark-modehurl
GET https://example.org/page
[Cookies]
session: abc123
preference: dark-modeVariables in Requests
请求中的变量
hurl
GET https://example.org/api/users/{{user_id}}
[Query]
expand: true
POST https://example.org/api/users
{
"name": "{{user_name}}",
"email": "{{user_email}}"
}Define variables via command line:
shell
$ hurl --variable user_id=123 --variable user_name="John" test.hurlOr use a variables file:
shell
$ hurl --variables-file config.json test.hurlhurl
GET https://example.org/api/users/{{user_id}}
[Query]
expand: true
POST https://example.org/api/users
{
"name": "{{user_name}}",
"email": "{{user_email}}"
}通过命令行定义变量:
shell
$ hurl --variable user_id=123 --variable user_name="John" test.hurl或使用变量文件:
shell
$ hurl --variables-file config.json test.hurlResponses
响应
Response sections describe expected HTTP responses and can include assertions and captures.
hurl
GET https://example.org/api
HTTP 200
Content-Type: application/json
[Asserts]
status == 200响应部分描述预期的HTTP响应,可包含断言和捕获。
hurl
GET https://example.org/api
HTTP 200
Content-Type: application/json
[Asserts]
status == 200Status Code
状态码
hurl
GET https://example.org/resource
HTTP 200Wildcard for any status:
hurl
GET https://example.org/resource
HTTP *
[Asserts]
status < 300hurl
GET https://example.org/resource
HTTP 200使用通配符匹配任意状态码:
hurl
GET https://example.org/resource
HTTP *
[Asserts]
status < 300Headers
响应头
hurl
GET https://example.org/resource
HTTP 200
Content-Type: application/json
Cache-Control: max-age=3600hurl
GET https://example.org/resource
HTTP 200
Content-Type: application/json
Cache-Control: max-age=3600Captures
捕获
Captures extract values from HTTP responses into variables for use in subsequent requests.
hurl
GET https://example.org/login
HTTP 200
[Captures]
csrf_token: xpath "normalize-space(//meta[@name='csrf-token']/@content)"
POST https://example.org/login
[Form]
csrf_token: {{csrf_token}}
username: user
password: pass
HTTP 302捕获功能可从HTTP响应中提取值到变量中,以便在后续请求中使用。
hurl
GET https://example.org/login
HTTP 200
[Captures]
csrf_token: xpath "normalize-space(//meta[@name='csrf-token']/@content)"
POST https://example.org/login
[Form]
csrf_token: {{csrf_token}}
username: user
password: pass
HTTP 302Capture Types
捕获类型
hurl
GET https://example.org/api/user
HTTP 200
[Captures]
user_id: jsonpath "$.id"
user_name: jsonpath "$.name"
email: jsonpath "$.email"
redirect_url: header "Location"
status: status
body_text: body
response_bytes: bytes
sha_hash: sha256hurl
GET https://example.org/api/user
HTTP 200
[Captures]
user_id: jsonpath "$.id"
user_name: jsonpath "$.name"
email: jsonpath "$.email"
redirect_url: header "Location"
status: status
body_text: body
response_bytes: bytes
sha_hash: sha256XPath Capture
XPath捕获
hurl
GET https://example.org/page
HTTP 200
[Captures]
title: xpath "string(//head/title)"
first_heading: xpath "string(//h1)"
csrf_token: xpath "normalize-space(//meta[@name='csrf_token']/@content)"hurl
GET https://example.org/page
HTTP 200
[Captures]
title: xpath "string(//head/title)"
first_heading: xpath "string(//h1)"
csrf_token: xpath "normalize-space(//meta[@name='csrf_token']/@content)"JSONPath Capture
JSONPath捕获
hurl
GET https://example.org/api/data
HTTP 200
[Captures]
user_id: jsonpath "$.user.id"
items_count: jsonpath "$.items.length()"
first_item: jsonpath "$.items[0]"hurl
GET https://example.org/api/data
HTTP 200
[Captures]
user_id: jsonpath "$.user.id"
items_count: jsonpath "$.items.length()"
first_item: jsonpath "$.items[0]"Regex Capture
正则表达式捕获
hurl
GET https://example.org/page
HTTP 200
[Captures]
id: regex "user-(\d+)"
version: regex /version\/(\d+\.\d+\.\d+)/hurl
GET https://example.org/page
HTTP 200
[Captures]
id: regex "user-(\d+)"
version: regex /version\/(\d+\.\d+\.\d+)/Duration Capture
响应时长捕获
hurl
GET https://example.org/api
HTTP 200
[Captures]
response_time: durationFilters can be applied to captures. See Filters Reference for available filters.
hurl
GET https://example.org/api
HTTP 200
[Captures]
response_time: duration可对捕获结果应用过滤器。有关可用过滤器,请参阅过滤器参考。
Certificate Capture
证书捕获
hurl
GET https://example.org
HTTP 200
[Captures]
cert_subject: certificate "Subject"
cert_issuer: certificate "Issuer"
cert_expiry: certificate "Expire-Date"hurl
GET https://example.org
HTTP 200
[Captures]
cert_subject: certificate "Subject"
cert_issuer: certificate "Issuer"
cert_expiry: certificate "Expire-Date"Assertions
断言
Assertions validate HTTP responses. They can be implicit (status, headers) or explicit in an section.
[Asserts]Filters can be applied to assertions to transform values before comparison. See Filters Reference for available filters.
hurl
GET https://example.org/api
HTTP 200
Content-Type: application/json
[Asserts]
jsonpath "$.status" == "success"
jsonpath "$.data.length()" == 10
header "X-Rate-Limit" exists断言用于验证HTTP响应。它们可以是隐式的(状态码、响应头),也可以显式定义在部分。
[Asserts]可对断言应用过滤器,在比较前转换值。有关可用过滤器,请参阅过滤器参考。
hurl
GET https://example.org/api
HTTP 200
Content-Type: application/json
[Asserts]
jsonpath "$.status" == "success"
jsonpath "$.data.length()" == 10
header "X-Rate-Limit" existsStatus Assertions
状态码断言
hurl
GET https://example.org/resource
HTTP 200
[Asserts]
status == 200
status >= 200
status < 300hurl
GET https://example.org/resource
HTTP 200
[Asserts]
status == 200
status >= 200
status < 300Header Assertions
响应头断言
hurl
GET https://example.org/resource
HTTP 200
[Asserts]
header "Content-Type" contains "application/json"
header "X-Request-Id" matches /^[a-f0-9]+$/
header "Cache-Control" == "max-age=3600"
header "Set-Cookie" count == 2hurl
GET https://example.org/resource
HTTP 200
[Asserts]
header "Content-Type" contains "application/json"
header "X-Request-Id" matches /^[a-f0-9]+$/
header "Cache-Control" == "max-age=3600"
header "Set-Cookie" count == 2Body Assertions
响应体断言
hurl
GET https://example.org/api
HTTP 200
[Asserts]
body contains "success"
body startsWith "{"
body endsWith "}"hurl
GET https://example.org/api
HTTP 200
[Asserts]
body contains "success"
body startsWith "{"
body endsWith "}"JSONPath Assertions
JSONPath断言
hurl
GET https://example.org/api/users
HTTP 200
[Asserts]
jsonpath "$.users[0].name" == "Alice"
jsonpath "$.users[*].active" contains true
jsonpath "$.count" != 0
jsonpath "$.users" count == 25
jsonpath "$.price" > 9.99
jsonpath "$.data" exists
jsonpath "$.items" isEmpty not
jsonpath "$.id" isInteger
jsonpath "$.price" isFloathurl
GET https://example.org/api/users
HTTP 200
[Asserts]
jsonpath "$.users[0].name" == "Alice"
jsonpath "$.users[*].active" contains true
jsonpath "$.count" != 0
jsonpath "$.users" count == 25
jsonpath "$.price" > 9.99
jsonpath "$.data" exists
jsonpath "$.items" isEmpty not
jsonpath "$.id" isInteger
jsonpath "$.price" isFloatXPath Assertions
XPath断言
hurl
GET https://example.org/page
HTTP 200
[Asserts]
xpath "string(//head/title)" == "Home Page"
xpath "count(//div)" == 5
xpath "//h1" exists
xpath "//error" not exists
xpath "boolean(count(//warning))" == falsehurl
GET https://example.org/page
HTTP 200
[Asserts]
xpath "string(//head/title)" == "Home Page"
xpath "count(//div)" == 5
xpath "//h1" exists
xpath "//error" not exists
xpath "boolean(count(//warning))" == falseRegex Assertions
正则表达式断言
hurl
GET https://example.org/page
HTTP 200
[Asserts]
regex "user:(\d+)" == "user:123"
regex /version:(\d+\.\d+)/ == "version:1.0"hurl
GET https://example.org/page
HTTP 200
[Asserts]
regex "user:(\d+)" == "user:123"
regex /version:(\d+\.\d+)/ == "version:1.0"Bytes Assertions
字节断言
hurl
GET https://example.org/file.zip
HTTP 200
[Asserts]
bytes count == 1024000
sha256 == hex,abc123...hurl
GET https://example.org/file.zip
HTTP 200
[Asserts]
bytes count == 1024000
sha256 == hex,abc123...Duration Assertions
响应时长断言
hurl
GET https://example.org/api
HTTP 200
[Asserts]
duration < 1000hurl
GET https://example.org/api
HTTP 200
[Asserts]
duration < 1000Certificate Assertions
证书断言
hurl
GET https://example.org
HTTP 200
[Asserts]
certificate "Subject" == "CN=example.org"
certificate "Issuer" == "C=US, O=Let's Encrypt"
certificate "Expire-Date" daysAfterNow > 30hurl
GET https://example.org
HTTP 200
[Asserts]
certificate "Subject" == "CN=example.org"
certificate "Issuer" == "C=US, O=Let's Encrypt"
certificate "Expire-Date" daysAfterNow > 30Predicates
谓词
Available predicates: , , , , , , , , , , , , , , , , , , , , , ,
==!=>>=<<=startsWithendsWithcontainsmatchesexistsisBooleanisEmptyisFloatisIntegerisIpv4isIpv6isIsoDateisListisNumberisObjectisStringisUuidAll predicates can be negated with :
nothurl
[Asserts]
header "Authorization" not exists
jsonpath "$.error" not contains "failed"可用谓词:, , , , , , , , , , , , , , , , , , , , , ,
==!=>>=<<=startsWithendsWithcontainsmatchesexistsisBooleanisEmptyisFloatisIntegerisIpv4isIpv6isIsoDateisListisNumberisObjectisStringisUuid所有谓词都可以用取反:
nothurl
[Asserts]
header "Authorization" not exists
jsonpath "$.error" not contains "failed"Chaining Requests
链式请求
Requests can be chained to create multi-step scenarios:
hurl
undefined请求可以链式执行,以创建多步骤场景:
hurl
undefinedGet CSRF token
Get CSRF token
GET https://example.org/login
HTTP 200
[Captures]
csrf_token: xpath "normalize-space(//input[@name='csrf']/@value)"
GET https://example.org/login
HTTP 200
[Captures]
csrf_token: xpath "normalize-space(//input[@name='csrf']/@value)"
Login with captured token
Login with captured token
POST https://example.org/login
[Form]
csrf: {{csrf_token}}
username: user
password: pass
HTTP 302
POST https://example.org/login
[Form]
csrf: {{csrf_token}}
username: user
password: pass
HTTP 302
Follow redirect to dashboard
Follow redirect to dashboard
GET https://example.org/dashboard
HTTP 200
[Asserts]
body contains "Welcome, user"
undefinedGET https://example.org/dashboard
HTTP 200
[Asserts]
body contains "Welcome, user"
undefinedControl Flow
控制流
Retry
重试
hurl
POST https://example.org/jobs
HTTP 201
[Captures]
job_id: jsonpath "$.id"
GET https://example.org/jobs/{{job_id}}
[Options]
retry: 10
retry-interval: 500ms
HTTP 200
[Asserts]
jsonpath "$.status" == "COMPLETED"hurl
POST https://example.org/jobs
HTTP 201
[Captures]
job_id: jsonpath "$.id"
GET https://example.org/jobs/{{job_id}}
[Options]
retry: 10
retry-interval: 500ms
HTTP 200
[Asserts]
jsonpath "$.status" == "COMPLETED"Skip
跳过
hurl
GET https://example.org/optional
[Options]
skip: true
HTTP 200hurl
GET https://example.org/optional
[Options]
skip: true
HTTP 200Repeat
重复
hurl
GET https://example.org/health
[Options]
repeat: 10
HTTP 200hurl
GET https://example.org/health
[Options]
repeat: 10
HTTP 200Delay
延迟
hurl
GET https://example.org/api
[Options]
delay: 2s
HTTP 200hurl
GET https://example.org/api
[Options]
delay: 2s
HTTP 200Redirection Handling
重定向处理
Manual Redirection Testing
手动重定向测试
hurl
GET https://example.org
HTTP 301
Location: https://www.example.org
GET https://www.example.org
HTTP 200hurl
GET https://example.org
HTTP 301
Location: https://www.example.org
GET https://www.example.org
HTTP 200Automatic Redirection
自动重定向
hurl
GET https://example.org
[Options]
location: true
HTTP 200
[Asserts]
url == "https://www.example.org"
redirects count == 1
redirects nth 0 location == "https://www.example.org"hurl
GET https://example.org
[Options]
location: true
HTTP 200
[Asserts]
url == "https://www.example.org"
redirects count == 1
redirects nth 0 location == "https://www.example.org"Secrets and Redaction
密钥与脱敏
Hide sensitive values from logs:
shell
$ hurl --secret api_key=abc123 test.hurlOr make captures redacted:
hurl
POST https://example.org/login
HTTP 200
[Captures]
token: header "X-Auth-Token" redact从日志中隐藏敏感值:
shell
$ hurl --secret api_key=abc123 test.hurl或对捕获结果进行脱敏:
hurl
POST https://example.org/login
HTTP 200
[Captures]
token: header "X-Auth-Token" redactCommand Line Options
命令行选项
Testing
测试
shell
$ hurl --test *.hurl # Test mode
$ hurl --test --jobs 4 *.hurl # Parallel test execution
$ hurl --test --repeat 100 *.hurl # Stress testshell
$ hurl --test *.hurl # Test mode
$ hurl --test --jobs 4 *.hurl # Parallel test execution
$ hurl --test --repeat 100 *.hurl # Stress testOutput Control
输出控制
shell
$ hurl -o output.json test.hurl # Write output to file
$ hurl --no-output test.hurl # Suppress output
$ hurl --include test.hurl # Include headers in output
$ hurl --color test.hurl # Colorize outputshell
$ hurl -o output.json test.hurl # Write output to file
$ hurl --no-output test.hurl # Suppress output
$ hurl --include test.hurl # Include headers in output
$ hurl --color test.hurl # Colorize outputReports
报告
shell
$ hurl --report-html results/ test.hurl # HTML report
$ hurl --report-json results/ test.hurl # JSON report
$ hurl --report-junit results.xml test.hurl # JUnit XML
$ hurl --report-tap results.tap test.hurl # TAP formatshell
$ hurl --report-html results/ test.hurl # HTML report
$ hurl --report-json results/ test.hurl # JSON report
$ hurl --report-junit results.xml test.hurl # JUnit XML
$ hurl --report-tap results.tap test.hurl # TAP formatDebugging
调试
shell
$ hurl --verbose test.hurl # Verbose output
$ hurl --very-verbose test.hurl # Very verbose (includes headers)
$ hurl --test --error-format long *.hurl # Detailed error outputshell
$ hurl --verbose test.hurl # Verbose output
$ hurl --very-verbose test.hurl # Very verbose (includes headers)
$ hurl --test --error-format long *.hurl # Detailed error outputRequest Options
请求选项
shell
$ hurl --location test.hurl # Follow redirects
$ hurl --compressed test.hurl # Request compressed response
$ hurl -u user:pass test.hurl # Basic auth
$ hurl -H "Header: value" test.hurl # Custom header
$ hurl -x proxy:8080 test.hurl # Use proxy
$ hurl --insecure test.hurl # Skip SSL verification
$ hurl --max-time 30 test.hurl # Timeout
$ hurl --retry 3 test.hurl # Retry on failureshell
$ hurl --location test.hurl # Follow redirects
$ hurl --compressed test.hurl # Request compressed response
$ hurl -u user:pass test.hurl # Basic auth
$ hurl -H "Header: value" test.hurl # Custom header
$ hurl -x proxy:8080 test.hurl # Use proxy
$ hurl --insecure test.hurl # Skip SSL verification
$ hurl --max-time 30 test.hurl # Timeout
$ hurl --retry 3 test.hurl # Retry on failureVariables
变量
shell
$ hurl --variable name=value test.hurl
$ hurl --variables-file vars.json test.hurl
$ HURL_VARIABLE_NAME=value hurl test.hurlshell
$ hurl --variable name=value test.hurl
$ hurl --variables-file vars.json test.hurl
$ HURL_VARIABLE_NAME=value hurl test.hurlFiles and Paths
文件与路径
shell
$ hurl --file-root /path/to/files test.hurl
$ hurl --glob "tests/**/*.hurl" # Find files by pattern
$ hurl dir/ # Run all .hurl files in directoryshell
$ hurl --file-root /path/to/files test.hurl
$ hurl --glob "tests/**/*.hurl" # Find files by pattern
$ hurl dir/ # Run all .hurl files in directoryTesting Best Practices
测试最佳实践
Use Test Mode
使用测试模式
shell
$ hurl --test test/api/*.hurlshell
$ hurl --test test/api/*.hurlGenerate Reports for CI/CD
为CI/CD生成报告
shell
$ hurl --test --report-junit results.xml --report-html reports/ tests/shell
$ hurl --test --report-junit results.xml --report-html reports/ tests/Organize Tests
组织测试用例
shell
tests/
api/
users.hurl
auth.hurl
products.hurl
integration/
checkout.hurl
search.hurl
smoke/
health.hurlshell
tests/
api/
users.hurl
auth.hurl
products.hurl
integration/
checkout.hurl
search.hurl
smoke/
health.hurlTest Performance
测试性能
hurl
GET https://example.org/api
HTTP 200
[Asserts]
duration < 500hurl
GET https://example.org/api
HTTP 200
[Asserts]
duration < 500Debug Failing Tests
调试失败的测试
shell
$ hurl --test --very-verbose --error-format long failing_test.hurlshell
$ hurl --test --very-verbose --error-format long failing_test.hurlCommon Patterns
常见模式
API Health Check
API健康检查
hurl
GET https://api.example.org/health
HTTP 200
[Asserts]
jsonpath "$.status" == "healthy"
jsonpath "$.version" existshurl
GET https://api.example.org/health
HTTP 200
[Asserts]
jsonpath "$.status" == "healthy"
jsonpath "$.version" existsREST API CRUD
REST API增删改查
hurl
undefinedhurl
undefinedCreate
Create
POST https://api.example.org/users
Content-Type: application/json
{
"name": "Test User",
"email": "test@example.com"
}
HTTP 201
[Captures]
user_id: jsonpath "$.id"
POST https://api.example.org/users
Content-Type: application/json
{
"name": "Test User",
"email": "test@example.com"
}
HTTP 201
[Captures]
user_id: jsonpath "$.id"
Read
Read
GET https://api.example.org/users/{{user_id}}
HTTP 200
[Asserts]
jsonpath "$.name" == "Test User"
GET https://api.example.org/users/{{user_id}}
HTTP 200
[Asserts]
jsonpath "$.name" == "Test User"
Update
Update
PUT https://api.example.org/users/{{user_id}}
Content-Type: application/json
{
"name": "Updated User"
}
HTTP 200
PUT https://api.example.org/users/{{user_id}}
Content-Type: application/json
{
"name": "Updated User"
}
HTTP 200
Delete
Delete
DELETE https://api.example.org/users/{{user_id}}
HTTP 204
undefinedDELETE https://api.example.org/users/{{user_id}}
HTTP 204
undefinedForm-based Login
基于表单的登录
hurl
GET https://example.org/login
HTTP 200
[Captures]
csrf: xpath "normalize-space(//input[@name='_csrf']/@value)"
POST https://example.org/login
[Form]
_csrf: {{csrf}}
username: myuser
password: mypass
HTTP 302
Location: /dashboard
[Asserts]
status == 302hurl
GET https://example.org/login
HTTP 200
[Captures]
csrf: xpath "normalize-space(//input[@name='_csrf']/@value)"
POST https://example.org/login
[Form]
_csrf: {{csrf}}
username: myuser
password: mypass
HTTP 302
Location: /dashboard
[Asserts]
status == 302GraphQL Query
GraphQL查询
hurl
POST https://api.example.org/graphql
```graphql
query GetUser($id: ID!) {
user(id: $id) {
id
name
email
posts {
title
}
}
}variables: {"id": "{{user_id}}"}
HTTP 200
[Asserts]
jsonpath "$.data.user.name" exists
jsonpath "$.errors" not exists
undefinedhurl
POST https://api.example.org/graphql
```graphql
query GetUser($id: ID!) {
user(id: $id) {
id
name
email
posts {
title
}
}
}variables: {"id": "{{user_id}}"}
HTTP 200
[Asserts]
jsonpath "$.data.user.name" exists
jsonpath "$.errors" not exists
undefinedSOAP Request
SOAP请求
hurl
POST https://example.org/soap-service
Content-Type: application/soap+xml; charset=utf-8
<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Body>
<GetProductInfo>
<productId>12345</productId>
</GetProductInfo>
</soap:Body>
</soap:Envelope>
HTTP 200
[Asserts]
xpath "boolean(//product/available)" == truehurl
POST https://example.org/soap-service
Content-Type: application/soap+xml; charset=utf-8
<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Body>
<GetProductInfo>
<productId>12345</productId>
</GetProductInfo>
</soap:Body>
</soap:Envelope>
HTTP 200
[Asserts]
xpath "boolean(//product/available)" == trueFile Reference
文件参考
Local Resources
本地资源
- Filters Reference - Available filters for transforming captured values and assertions
- Variables & Templates - Variables, templating, and secrets documentation
- Hurl File Format - File structure, comments, and special characters
- Request Format - HTTP method, URL, headers, body, auth, forms
- Response Format - Expected response, version, status, headers
- Captures - Extracting values from responses
- Assertions - Validating responses with asserts and predicates
- Running Tests - Test mode, reports, CI/CD integration
- Filters Reference - 用于转换捕获值和断言的可用过滤器
- Variables & Templates - 变量、模板和密钥文档
- Hurl File Format - 文件结构、注释和特殊字符
- Request Format - HTTP方法、URL、请求头、请求体、认证、表单
- Response Format - 预期响应、版本、状态码、响应头
- Captures - 从响应中提取值
- Assertions - 使用断言和谓词验证响应
- Running Tests - 测试模式、报告、CI/CD集成