04/10/2023, 8:38 AM
Is there a good sample of using Koin with Robolectric tests? I guess I don't know whether to use a KoinTestApp and pass that into Robolectric config. or I'm meant to use other APIs like a test Rule?
But only my first application test runs, the rest fail with
Scope '_root_' is closed
org.koin.core.error.ClosedScopeException: Scope '_root_' is closed
	at org.koin.core.scope.Scope.resolveInstance(Scope.kt:221)
	at org.koin.core.scope.Scope.get(Scope.kt:210)
	at org.koin.androidx.viewmodel.factory.KoinViewModelFactory.create(KoinViewModelFactory.kt:25)
	at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.kt:187)
	at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.kt:153)
	at org.koin.androidx.viewmodel.GetViewModelKt.resolveViewModel(GetViewModel.kt:44)
It seems like the old scope, now closed is retained by Compose composition locals, somehow? This gets me further
                LocalKoinScope provides KoinPlatformTools.defaultContext().get().scopeRegistry.rootScope,
                LocalKoinApplication provides KoinPlatformTools.defaultContext().get()
            ) {