extrawurst / grillon

🦗 Grillon, an elegant and natural way to approach end-to-end HTTP API testing in Rust.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Grillon

Crates.io docs.rs GitHub Workflow Status

Grillon offers an elegant and natural way to approach end-to-end HTTP API testing in Rust.

  • Elegant, intuitive and expressive API
  • Built-in testing functions
  • Extensible

Please note that the API is subject to a lot of changes until the v1.0.0.

Getting started

This example enables the optional diff feature and uses Tokio as asynchronous runtime. Generally, testing libs are used in unit or integration tests. You can declare grillon as a dev-dependency.

Add grillon to Cargo.toml

[dev-dependencies]
grillon = { version = "0.1.0", features = ["diff"] }
tokio = { version = "1", features = ["macros"] }

Then use grillon :

use grillon::{
    header::{HeaderValue, CONTENT_TYPE},
    json, Grillon, StatusCode, Result
};

#[tokio::test]
async fn end_to_end_test() -> Result<()> {
    Grillon::new("http://jsonplaceholder.typicode.com")?
        .post("posts")
        .payload(json!({
            "title": "foo",
            "body": "bar",
            "userId": 1
        }))
        .assert()
        .await
        .status_success()
        .status(StatusCode::CREATED)
        .headers_exist(vec![(
            CONTENT_TYPE,
            HeaderValue::from_static("application/json; charset=utf-8"),
        )])
        .body(json!({
            "id": 101,
        }));

    Ok(())
}

About

🦗 Grillon, an elegant and natural way to approach end-to-end HTTP API testing in Rust.

License:Apache License 2.0


Languages

Language:Rust 100.0%