Skip to main content

Crate anvil_test

Crate anvil_test 

Source
Expand description

Anvilforge test utilities — Pest-flavored HTTP and fluent expectations.

Import the prelude in your test files:

use anvilforge::assay::*;

#[tokio::test]
async fn root_returns_welcome() {
    let client = TestClient::new(bootstrap::app::build().await.unwrap()).await;

    client.get("/").await
        .assert_ok()
        .assert_see("Welcome");

    expect(2 + 2).to_be(4);
    expect("hello world").to_contain("world");
    expect(vec![1, 2, 3]).to_have_length(3);
}

Re-exports§

pub use client::TestClient;
pub use client::TestResponse;
pub use expect::expect;
pub use expect::Expect;
pub use expect::Not;
pub use factory::Factory;
pub use paste;

Modules§

assay
The Pest-style prelude. use anvilforge::assay::*; or use anvil_test::assay::*; to bring in the testing surface.
client
HTTP test client wrapping a tower::Service constructed from an Application.
datasets
Pest-style parameterized tests via the dataset! macro.
expect
Fluent assertions — Pest’s expect() translated to Rust.
factory
Model factory pattern. Each app-side factory implements Factory.

Macros§

dataset
Generate one #[test] per row. Each row is case_name => (arg1, arg2, ...). The closure parameter is a single tuple pattern + tuple type: |(n, sq): (i32, i32)|. For one-arg cases use |(n,): (i32,)|.
dataset_async
Async variant — generates #[tokio::test] per row.