So what is the recommended way of using Koin with ...
# koin
o
So what is the recommended way of using Koin with testing? Both documentation pages have different sample code: https://insert-koin.io/docs/reference/koin-test/testing https://insert-koin.io/docs/quickstart/junit-test/ Confusing
m
my approach that is working well is • Make your unit test class extend
KoinTest
• Inside of my
@Before
annotated method, I create a
module
and start koin
Copy code
val module = module {
    single { myMockInstance }
}
startKoin { modules(module) }
Then during tests, the mocked object
myMockInstance
gets injected into the classes under test • In of an
@After
annotated method, call
stopKoin()
not sure if this is exactly best practice, but it works well enough for me