Can anybody tell me if/how I can mock a supend funktion with koin test? The only thing I know so far is this behavior
declareMock<...> {
given(..)).willReturn(...)
}
but this doesn't work on suspend fun(). Is there anything similar to 'coEvery' in Mockk, or how can I do this?
Thanx in advance,
Wolfgang
Finally I found out how it works. You just can use any other mocking framework and use declare with that mock like so:
var preferenceRepository = mockk<PreferenceRepository>()
@Before
fun before() {
startKoin {
androidContext(ApplicationProvider.getApplicationContext())
}
declare {
factory { preferenceRepository }
}
}
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