Package-level declarations

Types

Link copied to clipboard
Link copied to clipboard
interface ClientProvider

A client attached to TestApplication.

Link copied to clipboard
open class ExpectedTestException(message: String) : Throwable

Exception that is expected to be thrown during test execution. It will not be logged and will not fail the test.

Link copied to clipboard

Registers mocks for external services.

Link copied to clipboard
object It

it function receiver object

Link copied to clipboard
object On

on function receiver object

Link copied to clipboard

A configured instance of a test application running locally.

Link copied to clipboard

A builder for TestApplication.

Link copied to clipboard
class TestApplicationCall(application: Application, readResponse: Boolean = false, closeRequest: Boolean = true, val coroutineContext: CoroutineContext) : BaseApplicationCall, CoroutineScope

A test application call that is used in withTestApplication and handleRequest.

Link copied to clipboard
class TestApplicationEngine(environment: ApplicationEnvironment = createTestEnvironment(), monitor: Events, developmentMode: Boolean = true, applicationProvider: () -> Application, configuration: TestApplicationEngine.Configuration) : BaseApplicationEngine, CoroutineScope

A test engine that provides a way to simulate application calls to the existing application module(s) without actual HTTP connection.

Link copied to clipboard
class TestApplicationRequest(call: TestApplicationCall, closeRequest: Boolean, var method: HttpMethod = HttpMethod.Get, var uri: String = "/", var port: Int? = null, var version: String = "HTTP/1.1") : BaseApplicationRequest, CoroutineScope

A test application request

Link copied to clipboard
class TestApplicationResponse(call: TestApplicationCall, readResponse: Boolean = false) : BaseApplicationResponse, CoroutineScope

A test call response received from a server.

Functions

Link copied to clipboard

Wait for websocket session completion

Link copied to clipboard

Returns a parsed content type from a test response.

Link copied to clipboard

Keeps cookies between requests inside the callback.

Link copied to clipboard

Creates an engine environment for a test application.

Link copied to clipboard

Makes a test request.

Link copied to clipboard
fun TestApplicationEngine.handleWebSocketConversation(uri: String, setup: TestApplicationRequest.() -> Unit = {}, awaitCallback: Boolean = true, callback: suspend TestApplicationCall.(incoming: ReceiveChannel<Frame>, outgoing: SendChannel<Frame>) -> Unit): TestApplicationCall

Makes a test request that sets up a WebSocket session and invokes the callback function that handles conversation with the server

Link copied to clipboard
inline fun On.it(description: String, body: It.() -> Unit)

DSL function for a test case assertions

Link copied to clipboard
fun on(comment: String, body: On.() -> Unit)

DSL for creating a test case

Link copied to clipboard

Sets an HTTP request body bytes.

Sets an HTTP request body text content.

Set HTTP request body from ByteReadPacket

Sets a multipart HTTP request body.

Link copied to clipboard

Creates an instance of TestApplication configured with the builder block. Make sure to call TestApplication.stop after your tests.

Link copied to clipboard
fun testApplication(block: suspend ApplicationTestBuilder.() -> Unit)
fun testApplication(parentCoroutineContext: CoroutineContext = EmptyCoroutineContext, block: suspend ApplicationTestBuilder.() -> Unit)

Creates a test using TestApplication. To test a server Ktor application, do the following:

Link copied to clipboard
fun <R> withApplication(environment: ApplicationEnvironment = createTestEnvironment(), configure: TestApplicationEngine.Configuration.() -> Unit = {}, test: TestApplicationEngine.() -> R): R

Starts a test application engine, passes it to the test function, and stops it.

Link copied to clipboard
fun <R> withTestApplication(moduleFunction: Application.() -> Unit, test: TestApplicationEngine.() -> R): R
fun <R> withTestApplication(moduleFunction: Application.() -> Unit, configure: TestApplicationEngine.Configuration.() -> Unit = {}, test: TestApplicationEngine.() -> R): R

Starts a test application engine, passes it to the test function, and stops it.