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

Aleksei Tirman [JB]

06/27/2022, 11:42 AM
Quick poll. Should a server under test be configured with
application.conf
from the
main
sourceset if the config in the
test
sourceset is absent?
👌
🚫
🚫 3
👌 9
a

antonarhipov

06/27/2022, 3:10 PM
Yes and no. for tests, it is rather important to be able to override the properties dynamically. Because if we speak of testing in the context of a web framework, it most likely means that we are talking about integration tests. And today people use containers to boot the external dependencies for such testing, e.g. Testcontainers. Hence, even if the test app can configure itself with application.conf it is not enough - it should be possible to override the individual properties depending on the conditions when the test is already running
2
(I know my answer wasn’t exactly to the question posted 🙂 but I couldn’t resist)
a

Aleksei Tirman [JB]

06/27/2022, 3:20 PM
So your point is that a
test
config should override properties in
main
config?
a

antonarhipov

06/27/2022, 3:22 PM
no-no-no. I think it wouldn’t be a great idea. picking up config from main if it’s not present in test is ok. but it should be possible to override the individual properties in the test code itself, doesn’t matter from where the config is loaded
2
here’s what you need to do to override the properties in ktor tests, and it is not nice https://github.com/antonarhipov/ktor-ws-chat/blob/master/src/test/kotlin/com/example/ApplicationTest.kt#L19-L30
👀 1
4 Views