Skip to content
Branch: master
Find file History


Sample project for Ktor demonstrating tests for Ktor applications.


Execute this command in the repository's root directory to run this sample:

./gradlew :testable:run

And navigate to http://localhost:8080/ to see the sample home page with a simple text string.

Writing tests

The simple test code looks like this:

   fun testRequests() = withTestApplication(Application::main) {
        with(handleRequest(HttpMethod.Get, "/")) {
            assertEquals(HttpStatusCode.OK, response.status())
            assertEquals("Hello from Ktor Testable sample application", response.content)

See ApplicationTest.kt

Running tests

To run the tests:

./gradlew :testable:test
You can’t perform that action at this time.