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

#383 in WebSocket

Download history 4687/week @ 2024-08-19 3985/week @ 2024-08-26 5673/week @ 2024-09-02 5869/week @ 2024-09-09 4983/week @ 2024-09-16 5500/week @ 2024-09-23 4445/week @ 2024-09-30 3132/week @ 2024-10-07 5029/week @ 2024-10-14 5320/week @ 2024-10-21 5633/week @ 2024-10-28 5604/week @ 2024-11-04 9588/week @ 2024-11-11 5360/week @ 2024-11-18 6327/week @ 2024-11-25 5952/week @ 2024-12-02

27,659 downloads per month
Used in 33 crates

MIT/Apache

2MB
39K 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
~511K SLoC