ey guys, I’m trying to define a clean arch for tes...
# exposed
j
ey guys, I’m trying to define a clean arch for testing in my Ktor + Exposed + Hikari project. Do you know if there is any good approach for unit testing those methods that define a transaction?
j
Sounds like a similar stack to what we are using - what specific problem(s) are you facing? We use JUnit for unit tests and component tests (Guice for injection to configure test environments and Ktor's
withTestApplication
) and cypress for e2e.
j
I also want to unit test the layer with the transaction
so finally I’ve managed by defining an interface for DbProvider and injecting with Koin the testing dbprovider so I dont need to use dbTransaction
I can still use dbQuery {} block in my controller layer
If anyone is interested I can explain my solution
j
sounds like you have found a strategy that works for your architecture 🙂
j
yep
thanks!
it is a bit messy with all the function extensions in Ktor structure 😄