Hurl HTTP requests as tests
Light · Postcard
102 × 152 mm · PDF
Dark · Postcard
102 × 152 mm · PDF
Ink saver · Postcard
102 × 152 mm · PDF
Light · A4 landscape
297 × 210 mm · PDF
Dark · A4 landscape
297 × 210 mm · PDF
Ink saver · A4 landscape
297 × 210 mm · PDF
Light · A3 landscape
420 × 297 mm · PDF
Dark · A3 landscape
420 × 297 mm · PDF
Ink saver · A3 landscape
420 × 297 mm · PDF
Start here
hurl <file.hurl>
hurl --test <file.hurl>
hurl --variable <name>=<value>
<file>
hurl -v <file>
hurl --very-verbose <file>
hurl --test --report-html <dir> <files>
hurl --retry <n> <file>
hurl --glob "<pattern>"
Concepts
- Request METHOD URL, headers, body
- Response HTTP 200
- Variables {{name}}
- [Asserts] pass or fail, exit code
Run
hurl <file.hurl>
hurl <a.hurl> <b.hurl>
hurl --test <files>
hurl --glob "<pattern>"
hurl --continue-on-error <file>
hurl --retry <n> --retry-interval <ms>
<file>
Request
GET <url><Name>: <value>
[Query] <key>: <value>
[Form] <key>: <value>
[BasicAuth] <user>: <password>
[Options] <option>: <value>
{ "key": "value" }
```json ... ```Response & Asserts
HTTP 200[Asserts]status < 300header "<Name>" contains
"<text>"
jsonpath "$.a.b" == "<value>"
jsonpath "$.items" count == <n>
xpath "//h1" exists
body contains "<text>"
jsonpath "$.x" not exists
Predicates
== != > >= < <=
startsWith endsWith contains
matches /<re>/
exists isEmptyisString isInteger isBoolean
Captures & Variables
[Captures]id: jsonpath "$.id"
tok: header "X-Token"
pass: header "token" redact
{{name}}hurl --variable <name>=<value>
hurl --variables-file <file>
hurl --secret <name>=<value>
Filters
HTTP options
-L, --location-H, --header <Name:value>
-u, --user <user:password>
-k, --insecure--compressed--resolve <host:port:addr>
-b <file> / -c <file>
Output & Reports
-v, --verbose--very-verbose-i, --include-o, --output <file>
--json--error-format long
-h, --help / -V, --version
--report-html <dir>
--report-junit <file>
| Code | Meaning |
|---|---|
0 |
Success |
1 |
Bad command-line options |
2 |
Hurl file parse error |
3 |
Runtime error (e.g. connection) |
4 |
Assert failed |
Recipes
POST https://api.example.com/login{ "user": "{{user}}", "pass": "{{pass}}" }HTTP 200[Captures]token: jsonpath "$.token" redactGET https://api.example.com/meAuthorization: Bearer {{token}}HTTP 200[Asserts]jsonpath "$.name" == "{{user}}"
GET https://api.example.com/jobs/{{id}}[Options]retry: 10retry-interval: 2000HTTP 200[Asserts]jsonpath "$.status" == "done"
hurl --test --variable host=https://staging.example.com \ --report-junit build/hurl.xml tests/*.hurl
POST https://api.example.com/upload[Query]folder: docs[Multipart]file: file,report.pdf; application/pdfHTTP 201



