Skip to content

Latest commit

 

History

History
 
 

testable

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

Testable

Sample project for Ktor demonstrating tests for Ktor applications.

Running

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