We have an android application with several modules. Some of them are pure kotlin modules and another ones are Android modules.
In the main module (android application), we want to have a test using checkModules function from Koin to check if injection is valid but it fails.
Error is about Room and other Android stuff implemented in some Android modules.
Must this be managed by Koin? Is there another option than do a mock over each android dependency?
Hello @Moussenger ,
try to add an Android mock module, to add to your modules when checking with checkModules():
val mockedAndroidContext = module {
single { mock(Application::class.java) }
}
This will give a mock instance of Application. Also give a single { mock(Context::class.java) } if you inject Context instance.
Most helpful comment
Hello @Moussenger ,
try to add an Android mock module, to add to your modules when checking with
checkModules():This will give a mock instance of
Application. Also give asingle { mock(Context::class.java) }if you injectContextinstance.