calidion
01/27/2025, 9:12 AMvar server = embeddedServer(
factory = Netty,
port = port,
host = host
) {
module(app)
}.start(wait = false)
Stephan Schröder
01/27/2025, 9:28 AMapp
. And then the server simply listens on its port of incoming requests.
Here is a link to the doc that uses a slightly configuration style: https://ktor.io/docs/server-create-a-new-project.html#change-the-default-portcalidion
01/27/2025, 9:40 AMhfhbd
01/27/2025, 10:09 AMcalidion
01/27/2025, 11:02 AMcalidion
01/27/2025, 11:03 AMcalidion
01/27/2025, 11:03 AMStephan Schröder
01/27/2025, 11:13 AMSystem.exit(0)
of course that'd also ends the tests 🤔Stephan Schröder
01/27/2025, 11:20 AMembeddedServer
is not used if you'd do test anyway
class ApplicationTest {
@Test
fun testRoot() = testApplication {
application {
module()
}
val response = client.get("/")
assertEquals(HttpStatusCode.OK, response.status)
assertEquals("Hello, world!", response.bodyAsText())
}
}
but maybe you're doing some kind of integration tests, so this doesn't apply?calidion
01/27/2025, 12:22 PMcalidion
01/27/2025, 12:23 PMcalidion
01/27/2025, 12:24 PMhfhbd
01/27/2025, 12:40 PMcalidion
01/27/2025, 1:32 PM