Hi I posted some questions on <#CRF31N2HW|koin-dev...
# koin
j
Hi I posted some questions on #koin-dev but I just found out about this channel so will post here as well, probably more appropriate: When overriding a module like in the documentation example: val myModuleA = module { single<Service> { ServiceImp() } } val myModuleB = module { single<Service> { TestServiceImp() } } // Will throw an BeanOverrideException startKoin { modules(myModuleA,myModuleB) } we see that koin create ServiceImp instance but even if we override it - any good way to avoid it ? It is a ktor-koin project and we have some scheduler in the ServiceImp init that we don’t want to start at all when just running the tests Thanks
k
I thought there was an override parameter you could use
j
I ll add a bit more details to my question: We are using ktor and we install koin in the ktor application
Copy code
fun Application.main() {

    install(Koin) {
        modules(modules)
    }
}
now in the module we have various Services we want koin to inject. In the test we want to override the those service and skip their loading since some of them are triggering async tasks at their init block.
a
2 options then, override definitions with dedicated module for test else use
declareMock
to override on the fly a definition - https://insert-koin.io/docs/reference/koin-test/testing