The solution is quite simple, you need to create a singleton containing a koin instance and in the test base class simply override the getKoin method, which will receive the instance from the singleton.
Singleton with koin instance
object MyIsolatedKoinContext {
val koinApp = koinApplication {
// declare used modules
modules(koinModule)
}
val koin = koinApp.koin
}
Test base class
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
abstract class BaseTest : KoinTest {
override fun getKoin(): Koin = MyIsolatedKoinContext.koin
}
The solution is quite simple, you need to create a singleton containing a koin instance and in the test base class simply override the getKoin method, which will receive the instance from the singleton.
Singleton with koin instance
Test base class