Hurl 2.0.0, run and test HTTP requests with plain text
I'm the maintainer of Hurl, an Open Source command line tool that allow you to test REST APIs and HTML content with simple plain text files. Hurl is a lightweight fast single binary, available on Windows, Linux, macOS (through various packet managers brew, npm etc...), based on curl, and well adapted for integration tests.
A Hurl sample:
POST https://example.org/api/tests
{
"id": "4568",
"evaluate": true
}
HTTP 200
[Asserts]
header "X-Frame-Options" == "SAMEORIGIN"
jsonpath "$.status" == "RUNNING" # Check the status code
jsonpath "$.tests" count == 25 # Check the number of items
jsonpath "$.id" matches /\\d{4}/ # Check the format of the id
Hurl has been designed to be used on local dev and also easily integrated in CI/CD (like GitHub Actions or GitLab CI/CD for instance).
Hurl is really fast, and its text format make it suitable for both devops and developers. If you're intrigued, we've written a step-by-step tutorial that shows how you can test a simple website and add integration tests with GitHub Actions.
In this new 2.0.0 version, we're supporting GraphQL query with a simple syntax (in my opinion):
POST https://api.github.com/graphql
Authorization: bearer {{token}}
```graphql
{
repository(owner: "Orange-OpenSource", name: "hurl") {
stargazerCount
}
}
```
HTTP 200
And this Hurl file can be run like this:
$ hurl --variable token=FOO github.hurl | jq
{
"data": {
"repository": {
"stargazerCount": 3578
}
}
}
GraphQL queries, of course, can use GraphQL variables:
POST https://api.starwars.com/graphql
```graphql
query HeroNameAndFriends($episode: Episode) {
hero(episode: $episode) {
name
friends {
name
}
}
}
variables {
"episode": "JEDI"
}
```
HTTP 200
We can finally add asserts on the HTTP response:
POST https://api.starwars.com/graphql
```graphql
{
human(id: "1000") {
name
height
}
}
```
HTTP 200
[Asserts]
jsonpath "$.data.human.name" == "Luke Skywalker"
jsonpath "$.data.human.height" == 1.72
Hurl can't exist without a lot of crates, and particularly curl-rust https://crates.io/crates/curl. Huge thanks to the maintainers!
Happy to have feedbacks on Hurl,