Skip to content

Commit

Permalink
Merge pull request #1957 from wagarcdev/patch-1
Browse files Browse the repository at this point in the history
fix: subsequent instrumented tests failing
  • Loading branch information
arnaudgiuliani committed Sep 17, 2024
2 parents a94b1b4 + 5121139 commit 165dda9
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions docs/reference/koin-android/instrumented-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,19 @@ class KoinTestRule(
private val modules: List<Module>
) : TestWatcher() {
override fun starting(description: Description) {
startKoin {
androidContext(InstrumentationRegistry.getInstrumentation().targetContext.applicationContext)
modules(modules)

if (getKoinApplicationOrNull() == null) {
startKoin {
androidContext(InstrumentationRegistry.getInstrumentation().targetContext.applicationContext)
modules(modules)
}
} else {
loadKoinModules(modules)
}
}

override fun finished(description: Description) {
stopKoin()
unloadKoinModules(modules)
}
}
```
Expand Down

0 comments on commit 165dda9

Please sign in to comment.