Struct actix_web::test::TestServer

source ·
pub struct TestServer { /* private fields */ }
Expand description

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 mut srv = TestServer::new(|app| app.handler(my_handler));

let req = srv.get().finish().unwrap();
let response = srv.execute(req.send()).unwrap();
assert!(response.status().is_success());

Implementations

Start new test server

This method accepts configuration method. You can add middlewares or set handlers for test application.

Create test server builder

Create test server builder with specific state factory

This method can be used for constructing application state. Also it can be used for external dependency initialization, like creating sync actors for diesel integration.

Start new test server with application factory

Get firat available unused address

Construct test server url

Construct test server url

Execute future on current core

Connect to websocket server at a given path

Connect to a websocket server

Create GET request

Create POST request

Create HEAD request

Connect to test http server

Trait Implementations

Executes the destructor for this type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.