Skip to content
Latchkey

How to Run Hurl API Tests in CI

Hurl runs plain-text HTTP files and asserts on responses, so an API smoke test is a few lines of text.

Write requests and assertions in a .hurl file, then run hurl --test. Add --report-junit so results appear as a JUnit artifact.

Steps

  • Write requests and [Asserts] blocks in a .hurl file.
  • Install Hurl (a release binary or the setup action).
  • Run hurl --test over your files with --report-junit.

Test file

test.hurl
GET https://api.example.com/health
HTTP 200
[Asserts]
jsonpath "$.status" == "ok"

POST https://api.example.com/login
Content-Type: application/json
{ "user": "ci", "pass": "{{PASSWORD}}" }
HTTP 200
[Asserts]
jsonpath "$.token" exists

Workflow

.github/workflows/ci.yml
jobs:
  hurl:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: gacts/install-hurl@v1
      - run: hurl --test --report-junit results/hurl.xml --variable PASSWORD=${{ secrets.API_PASSWORD }} tests/*.hurl

Gotchas

  • Pass secrets with --variable NAME=value, not hard-coded in the .hurl file.
  • Capture a value from one request with [Captures] and reuse it in the next for login flows.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →