Hi folks I have multiple junit tests based on koin...
# koin
l
Hi folks I have multiple junit tests based on koin Any idea how I could easily run tests in parallel? Looks like koin has a global context, and tests are not isolated (changing the junit config, I got errors like "koin already started")
w
probably context isolation
but unsure since I’ve not run into this specific scenario
a
yes, using
koinApplication
instead of
startKoin
is making local context instead of global one. Depends your usage behind
l
I want to use it for tests, however that doesn't work because : • in tests I create a
koinApplication
with my modules • then I declare some mocks on top within it • I also declare the
KoinComponent
I want to test • in the
KoinComponent
I get other dependencies using by
inject<OtherDep>()
=> injection fails because
KoinApplication has not been started
it looks like within a
koinApplication
,
inject
resolves dependencies using the global context Do I understand well? Is that expected? It doesn't sound logical