pub fn server<F, S, I>(factory: F) -> TestServerExpand description
Start test server
TestServer is very simple test server that simplify process of writing
integration tests cases for ntex web applications.
ยงExamples
use ntex::http::{self, Method, Response};
#[ntex::test]
async fn test_example() {
let srv = http::test::server(async |_| {
http::HttpService::h1(async |_| Ok::<_, std::io::Error>(Response::Ok().build()))
});
let req = srv.request(Method::GET, "/");
let response = req.send().await.unwrap();
assert!(response.status().is_success());
}