[−][src]Function actix_http_test::test_server
pub async fn test_server<F: ServiceFactory<TcpStream>>(factory: F) -> TestServer
Start test server
TestServer
is very simple test server that simplify process of writing
integration tests cases for actix web applications.
Examples
use actix_http::HttpService; use actix_http_test::TestServer; use actix_web::{web, App, HttpResponse, Error}; async fn my_handler() -> Result<HttpResponse, Error> { Ok(HttpResponse::Ok().into()) } #[actix_rt::test] async fn test_example() { let mut srv = TestServer::start( || HttpService::new( App::new().service( web::resource("/").to(my_handler)) ) ); let req = srv.get("/"); let response = req.send().await.unwrap(); assert!(response.status().is_success()); }