- server config outsourced
- test integrated
This commit is contained in:
@@ -1,15 +1,27 @@
|
||||
package at.mocode
|
||||
|
||||
import org.junit.jupiter.api.Assertions.*
|
||||
import org.junit.jupiter.api.Test
|
||||
import io.ktor.client.request.*
|
||||
import io.ktor.client.statement.*
|
||||
import io.ktor.http.*
|
||||
import io.ktor.server.testing.* // Wichtig für testApplication
|
||||
import kotlin.test.* // Wichtig für assertEquals, assertTrue etc.
|
||||
|
||||
class ApplicationTest {
|
||||
@Test
|
||||
fun main() {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun module() {
|
||||
fun testRootRoute() = testApplication {
|
||||
application {
|
||||
module() // Ruft deine Konfigurationsfunktion auf
|
||||
}
|
||||
|
||||
// Sendet eine GET-Anfrage an "/" innerhalb der Test-App
|
||||
val response = client.get("/")
|
||||
|
||||
// Überprüfungen (Assertions)
|
||||
assertEquals(HttpStatusCode.OK, response.status, "Status Code should be OK")
|
||||
val content = response.bodyAsText() // Holt den HTML-Body als Text
|
||||
assertTrue(content.contains("Ktor: Hello, Java 21.0.6!"), "Welcome message missing")
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user