class TestApplicationEngine : BaseApplicationEngine, CoroutineScope
ktor test engine that provides way to simulate application calls to existing application module(s) without actual HTTP connection
class Configuration : Configuration
Test application engine configuration |
TestApplicationEngine(environment: ApplicationEngineEnvironment = createTestEnvironment(), configure: Configuration.() -> Unit = {})
ktor test engine that provides way to simulate application calls to existing application module(s) without actual HTTP connection |
var callInterceptor: <ERROR CLASS><Unit, ApplicationCall>
interceptor for engine calls. can be modified to emulate certain engine behaviour (e.g. error handling) |
|
val client: HttpClient
A client instance connected to this test server instance. Only works until engine stop invocation. |
|
val coroutineContext: <ERROR CLASS> |
|
val engine: HttpClientEngine
An instance of client engine user to be used in client. |
fun createCall(readResponse: Boolean = false, closeRequest: Boolean = true, setup: TestApplicationRequest.() -> Unit): TestApplicationCall
Creates an instance of test call but doesn't start request processing |
|
fun handleRequest(closeRequest: Boolean = true, setup: TestApplicationRequest.() -> Unit): TestApplicationCall
Make a test request |
|
fun handleWebSocket(uri: String, setup: TestApplicationRequest.() -> Unit): TestApplicationCall
Make a test request that setup a websocket session and wait for completion |
|
fun handleWebSocketConversation(uri: String, setup: TestApplicationRequest.() -> Unit = {}, callback: suspend TestApplicationCall.(incoming: ReceiveChannel<Frame>, outgoing: SendChannel<Frame>) -> Unit): TestApplicationCall
Make a test request that setup a websocket session and invoke callback function that does conversation with server |
|
fun hookRequests(processRequest: TestApplicationRequest.(setup: TestApplicationRequest.() -> Unit) -> Unit, processResponse: TestApplicationCall.() -> Unit, block: () -> Unit): Unit
Install a hook for test requests |
|
fun start(wait: Boolean): ApplicationEngine |
|
fun stop(gracePeriodMillis: Long, timeoutMillis: Long): Unit |
fun TestApplicationEngine.cookiesSession(callback: () -> Unit): Unit
Keep cookies between requests inside the callback. |
|
fun TestApplicationEngine.handleRequest(method: HttpMethod, uri: String, setup: TestApplicationRequest.() -> Unit = {}): TestApplicationCall
Make a test request |