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}")}Boot an application
Section titled “Boot an application”TestApplication.create(base, *providers) is a thin wrapper around Kona.create("--base=…").providers(…).boot().
@TempDirlateinit var base: Path
val app = TestApplication.create( base, HttpServiceProvider(), MyAppProvider(),)Path base = Files.createTempDirectory("app");Application app = TestApplication.create( base, new HttpServiceProvider(), new 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.
What to assert next
Section titled “What to assert next”| Guide | Surface |
|---|---|
| HTTP tests | HttpTestClient / TestResponse |
| Console tests | ConsoleTester / ConsoleResult |
| Database & fakes | DatabaseTest, FakeMail, FakeQueue, FakeEvent, … |
Java sample
Section titled “Java sample”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.