[−][src]Function actori_http_test::test_server
pub 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 actori web applications.
Examples
use actori_http::HttpService; use actori_http_test::TestServer; use actori_web::{web, App, HttpResponse, Error}; async fn my_handler() -> Result<HttpResponse, Error> { Ok(HttpResponse::Ok().into()) } #[actori_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()); }