Skip to content

API Testing with Hurl

skitsanos edited this page Aug 21, 2022 · 2 revisions

You can use Hurl to test your API endpoints.

Hurl is a command-line tool that runs HTTP requests defined in a simple plain text format.

It can perform requests, capture values, and evaluate queries on headers and body responses. Hurl is very versatile: it can be used for both fetching data and testing HTTP sessions.

There are two ways you can run hurl tests, - via the docker container or by having hurl installed.

Testing with hurl running in docker:

docker run --network host --rm -it -v "$(pwd)/.api-test":/app "orangeopensource/hurl:latest" --test --variables-file /app/.vars /app/hello.hurl

Or, if you already have to hurl installed (Installation instructions)

hurl --test --variables-file .api-test/.vars .api-test/*.hurl

.vars file contains variables needed for your tests and can look like this:

URL=http://localhost:8529/_db/dev/api

So, all together with variables, you can make an API test that will check if your API is up:

GET {{URL}}/

HTTP/* 200

The {{URL}} referres to URL variable from .vars file.

Clone this wiki locally