Struct actix_web::test::TestServer
[−]
[src]
pub struct TestServer { /* fields omitted */ }
The TestServer
type.
TestServer
is very simple test server that simplify process of writing
integration tests cases for actix web applications.
Examples
use actix_web::test::TestServer; let srv = TestServer::new(|app| app.handler(my_handler)); assert!(reqwest::get(&srv.url("/")).unwrap().status().is_success());
Methods
impl TestServer
[src]
fn new<F>(config: F) -> Self where
F: Sync + Send + 'static + Fn(&mut TestApp<()>),
[src]
F: Sync + Send + 'static + Fn(&mut TestApp<()>),
Start new test server
This method accepts configuration method. You can add middlewares or set handlers for test application.
fn with_factory<H, F, U, V>(factory: F) -> Self where
H: HttpHandler,
F: Sync + Send + 'static + Fn() -> U,
U: IntoIterator<Item = V> + 'static,
V: IntoHttpHandler<Handler = H>,
[src]
H: HttpHandler,
F: Sync + Send + 'static + Fn() -> U,
U: IntoIterator<Item = V> + 'static,
V: IntoHttpHandler<Handler = H>,
Start new test server with application factory
fn with_state<S, FS, F>(state: FS, config: F) -> Self where
S: 'static,
FS: Sync + Send + 'static + Fn() -> S,
F: Sync + Send + 'static + Fn(&mut TestApp<S>),
[src]
S: 'static,
FS: Sync + Send + 'static + Fn() -> S,
F: Sync + Send + 'static + Fn(&mut TestApp<S>),
Start new test server with custom application state
This method accepts state factory and configuration method.
fn unused_addr() -> SocketAddr
[src]
Get firat available unused address
fn addr(&self) -> SocketAddr
[src]
Construct test server url
fn url(&self, uri: &str) -> String
[src]
Construct test server url