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.
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)
}
}
To run the tests:
./gradlew :testable:test