Skip to content
Kona

Testing

kona-testing is the test harness for Kona applications. It boots a real Application under a temporary base path, then drives HTTP, grind, the database, and in-memory fakes without opening sockets or touching production services.

Add it as a test dependency:

dependencies {
testImplementation("org.konaframework:kona-testing:${konaVersion}")
}

TestApplication.create(base, *providers) is a thin wrapper around Kona.create("--base=…").providers(…).boot().

@TempDir
lateinit var base: Path
val app = TestApplication.create(
base,
HttpServiceProvider(),
MyAppProvider(),
)

Register routes, bindings, and middleware in the providers you pass (or after boot). Tear down is usually “throw away the temp directory” — prefer fresh bases over reusing long-lived apps across tests.

Guide Surface
HTTP tests HttpTestClient / TestResponse
Console tests ConsoleTester / ConsoleResult
Database & fakes DatabaseTest, FakeMail, FakeQueue, FakeEvent, …

modules/testing ships JavaTestingApiTest — the same APIs are @JvmStatic / Java-callable. Prefer Kotlin examples above; call the identical types from Java when your app tests are Java-first.