aedenj / ktor-starter

0 stars 0 forks source link

increase code coverage to 100% #29

Open aedenj opened 2 months ago

aedenj commented 2 months ago

Need to cover,

fun main(args: Array<String>): Unit = io.ktor.server.netty.EngineMain.main(args)
aedenj commented 2 months ago

Consider this ignore solution. https://github.com/Kotlin/kotlinx-kover/issues/431

aedenj commented 2 months ago

Use https://java.testcontainers.org/features/creating_container/ for the e2e test.

Potetnially useful code, https://github.com/sureshg/testcontainers-kotlin/tree/master

aedenj commented 1 month ago

This test wil increase coverage to 100%

@OptIn(DelicateCoroutinesApi::class)
@Test
fun `should start the service again`(): Unit =
        runBlocking {
            val job =
                GlobalScope.launch {
                    main(emptyArray<String>())
                }

            Thread.sleep(3000)
            val response = HttpClient().get("http://localhost:8080/")

            job.cancel()
            assertThat(response.bodyAsText()).isEqualTo("Hello, world!")
        }

However its formulation is a little problematic. e.g. optin requirement