Emirhan Emmez
12/06/2021, 10:19 AMwithTestApplication {
handleRequest(HttpMethod.Get, "/hello").apply {
assertEquals(HttpStatusCode.OK, response.status())
}
}
Aleksei Tirman [JB]
12/06/2021, 10:20 AMEmirhan Emmez
12/06/2021, 10:21 AMroute("/hello") {
get {
call.respondText(text = "Hello", status = HttpStatusCode.OK)
}
}
Aleksei Tirman [JB]
12/06/2021, 10:22 AM@Test
fun test() {
withTestApplication {
application.routing {
route("/hello") {
get {
call.respondText(text = "Hello", status = HttpStatusCode.OK)
}
}
}
handleRequest(HttpMethod.Get, "/hello").apply {
assertEquals(HttpStatusCode.OK, response.status())
}
}
}
Emirhan Emmez
12/06/2021, 10:23 AMAleksei Tirman [JB]
12/06/2021, 10:24 AMclass Test {
@Test
fun test() {
withTestApplication {
application.myRouting()
handleRequest(HttpMethod.Get, "/hello").apply {
assertEquals(HttpStatusCode.OK, response.status())
}
}
}
}
fun Application.myRouting() {
routing {
route("/hello") {
get {
call.respondText(text = "Hello", status = HttpStatusCode.OK)
}
}
}
}
Emirhan Emmez
12/06/2021, 10:26 AMContentNegotiation
Aleksei Tirman [JB]
12/06/2021, 1:49 PM