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

#350 in WebSocket

Download history 5684/week @ 2024-07-21 4961/week @ 2024-07-28 6148/week @ 2024-08-04 7699/week @ 2024-08-11 4727/week @ 2024-08-18 4029/week @ 2024-08-25 5564/week @ 2024-09-01 5422/week @ 2024-09-08 5491/week @ 2024-09-15 5522/week @ 2024-09-22 4552/week @ 2024-09-29 2992/week @ 2024-10-06 4509/week @ 2024-10-13 5921/week @ 2024-10-20 5500/week @ 2024-10-27 5400/week @ 2024-11-03

21,601 downloads per month
Used in 32 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