https://kotlinlang.org logo
#ktor
Title
# ktor
g

Giovanni Alluvatti

05/05/2020, 9:52 AM
Hello there! I have a question on how to test e2e (making rest calls) a ktor+kodein application. The test should be included in the application project. I can explain better with a comparison to spring boot since I'm migrating from it. In Spring Boot I can create a test annotated with
@SpringBootTest
, starting up my application with a real context (no mocks); then using a
TestRestTemplate
I can call my rest api exposed to
<http://localhost>:{springBootRandomPort}
. Does anybody know a similar smart way to test this scenario also for a ktor + kodein app? Unfortunately I wasn't able to find any examples on official documentation.
c

crummy

05/05/2020, 9:17 PM
Do they have to be actual REST calls? Ktor has a great
withTestApplication
function that spins up nearly your whole app, but doesn't actually listen on HTTP.
g

Giovanni Alluvatti

05/06/2020, 7:29 AM
Yes, they have to be actual rest calls and my understanding is, as you said, that
withTestApplication
doesn't spin up the whole app, and my goal is to test the whole app listening on HTTP.
2 Views