https://kotlinlang.org logo
#koin-contributors
Title
# koin-contributors
s

Shalom Halbert

11/27/2021, 1:28 PM
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

arnaud.giuliani

12/02/2021, 8:59 AM
Great feedback. Worth to have a clear walkthrough in doc yes 👍
s

Shalom Halbert

12/13/2021, 5:05 PM
Where is the webpage content stored? I’d be happy to contribute a draft
a

arnaud.giuliani

12/14/2021, 9:03 AM
in the github repo, you can start a new markdown page: https://github.com/InsertKoinIO/koin/tree/main/docs/reference/koin-android
s

Shalom Halbert

12/15/2021, 5:39 PM
a

arnaud.giuliani

12/16/2021, 10:57 AM
Great 🙏
15 Views