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.hurlfile. - Install Hurl (a release binary or the setup action).
- Run
hurl --testover 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" existsWorkflow
.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/*.hurlGotchas
- Pass secrets with
--variable NAME=value, not hard-coded in the.hurlfile. - Capture a value from one request with
[Captures]and reuse it in the next for login flows.
Related guides
How to Handle Auth Tokens for API Tests in CIAuthenticate API tests in GitHub Actions by fetching a token at runtime or reading one from secrets, then pas…
How to Publish an API Test JUnit Report in CIEmit a JUnit XML report from any API test runner in GitHub Actions and publish it, so passed and failed reque…
How to Run Data-Driven API Tests in CIRun the same API test over many input rows in GitHub Actions with pytest parametrize or a Newman CSV data fil…