hey guys, is there any tutorial on how to use <htt...
# ktor
h
hey guys, is there any tutorial on how to use https://testcontainers.com/ to test a ktor server implementation running a postgresql/mysql database?
a
h
i can see that you have a runBlocking as a means to test the
client.X
functionality, although the docs point out to this kind of usage (see image), i’m a bit confused, what’s the difference and which one should i be using?
a
That's because I extracted the testapplication into a field in the test to reuse the instance of the application: https://github.com/antonarhipov/ktor-workshop/blob/branch08/src/test/kotlin/jetbrains/org/ControllerIntegrationTest.kt#L28-L40
h
thank you, i got it working as well, didn’t know that you had to have docker running in order to run the test containers my impl. looks like this
a
There are two tests that use the TestContainers 1. DatabaseIntegrationTest - doesn't use TestApplication instance all all as it tests the service directly. Here I need runBlocking because some methods required coroutine scope 2. ControllerIntegrationTest - uses TestApplication as the tests are calling the application APIs via the client. Same issue with coroutine scope
didn’t know that you had to have docker running in order to run the test containers
sure. Docker compatible environment is required to start the containers. I can be anything else than Docker, AFAIK, but I haven't tried
gratitude thank you 1