I want to write test for koin
. I use RoomDatabase
, which receives context in constructor. App works well but test fails
Can't resolve Application instance. Please use androidContext() function in your KoinApplication configuration.
if you want context in your modules, you should pass context in your start koin method
// start Koin!
startKoin {
// declare used Android context
androidContext(this@MyApplication)
// declare modules
modules(yourModule)
}
and use these libraries
// Koin AndroidX Scope features
implementation "org.koin:koin-android-scope:2.0.1"
// Koin AndroidX ViewModel features
implementation 'org.koin:koin-androidx-viewmodel:2.0.1'
// Koin AndroidX Experimental features
implementation "org.koin:koin-android-ext:2.0.1"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With