Я начал использовать Koin, и мне нужно протестировать ViewModel, который просит репозиторий получить файл из внутренней памяти телефона.
Когда я устанавливаю тест ViewModel, я делаю:
@Before
fun setup() {
startKoin {
modules(dataModule)
}
declareMock<Repository> {
fakeAccount = moshiAccountAdapter.fromJson(json)
whenever(this.getAccount()).thenReturn(fakeAccount)
}
}
но метод getAccount репозитория - suspend fun getAccount(): Account?, поэтому в классе ViewModelTest появляется сообщение suspend function getAccount should be called only from a coroutine or from another suspending function.
Заранее спасибо!