Spent a bunch of time trying to setup Koin for ins...
# koin-contributors
s
Spent a bunch of time trying to setup Koin for instrumented tests. Started by trying to use
loadModules
and
unloadModules
, which worked…until I found out it that the module didn’t load before tests started. That yielded test failures that were difficult to debug. The solution, that doesn’t require test code in production code, was to: 1. Create a new class that extends the production
Application
class, let’s call the child
InstrumentedTestApplication
2. In
InstrumentedTestApplication
, override the list of modules provided in `startKoin`’s
modules
declaration to include a
testModule
3. Create a new class that extends
AndroidJunitRunner
, let’s call it
InstrumentedTestJunitRunner
that will instantiate
InstrumentedTestApplication
4. Point
testInstrumentationRunner
in the app-level build.gradle to
InstrumentedTestJunitRunner
Is this something that is in the Koin documentation, and I missed it? If not, is there interest in having it added?
a
Great feedback. Worth to have a clear walkthrough in doc yes 👍
s
Where is the webpage content stored? I’d be happy to contribute a draft
a
in the github repo, you can start a new markdown page: https://github.com/InsertKoinIO/koin/tree/main/docs/reference/koin-android
s
a
Great 🙏