Closed ahinchman1 closed 4 years ago
java.lang.IllegalStateException: No root scoped initialised
is typical of something that tries to run on Koin, but it has not been started. ViewModel will follow lifecycle, try to not use scopes as much as you can.
Should perhaps update your start:
@get:Rule
val koinTestRule = KoinTestRule.create {
printLogger(Level.DEBUG)
modules( // modules here)
}
}
Hi! It's likely this is not a bug, but I'm perplexed about why my ViewModel unit test keeps asking for a root scope to be initialized when it wasn't necessary for weaving Koin in to the actual project.
Scoping didn't appear to be relevant for the actual implementation, so why does it matter for testing? In other examples I've viewed, there's appears nothing needed regarding scope in other examples I've seen.
Error message:
I've tried several different combinations all the with the same result:
I also moved the Koin module to individual tests to see if that gave me anything different (it removed the context already initialized issue, but I am still getting the same error
Even when I attempted to add the scope, I was still getting the same error message:
Any pointers would be greatly appreciated! Thanks!