20 releases

0.1.5 Jun 9, 2024
0.1.3 Feb 4, 2024
0.1.2 Aug 29, 2023
0.1.1 Feb 26, 2023
0.0.1 Mar 19, 2021

#935 in HTTP server

Download history 5802/week @ 2024-03-14 5566/week @ 2024-03-21 4468/week @ 2024-03-28 5349/week @ 2024-04-04 4742/week @ 2024-04-11 6392/week @ 2024-04-18 6304/week @ 2024-04-25 5620/week @ 2024-05-02 7596/week @ 2024-05-09 4873/week @ 2024-05-16 5432/week @ 2024-05-23 4098/week @ 2024-05-30 6040/week @ 2024-06-06 6337/week @ 2024-06-13 6298/week @ 2024-06-20 4295/week @ 2024-06-27

23,571 downloads per month
Used in 24 crates

MIT/Apache

2MB
38K SLoC

actix-test

crates.io Documentation Version MIT or Apache 2.0 licensed
dependency status Download Chat on Discord

Integration testing tools for Actix Web applications.

The main integration testing tool is TestServer. It spawns a real HTTP server on an unused port and provides methods that use a real HTTP client. Therefore, it is much closer to real-world cases than using init_service, which skips HTTP encoding and decoding.

Examples

use actix_web::{get, web, test, App, HttpResponse, Error, Responder};

#[get("/")]
async fn my_handler() -> Result<impl Responder, Error> {
    Ok(HttpResponse::Ok())
}

#[actix_rt::test]
async fn test_example() {
    let srv = actix_test::start(||
        App::new().service(my_handler)
    );

    let req = srv.get("/");
    let res = req.send().await.unwrap();

    assert!(res.status().is_success());
}

Dependencies

~15–29MB
~526K SLoC