Hi, I am writing an android instrumentation test to test one of my fragments. The fragment uses a (real) viewmodel and I have declared mocks for it to use. The issue is one of these mocks (a repository class) has a suspend function and I am not sure what to do in the test.
m
Martin Rajniak
01/04/2022, 2:52 PM
I am not sure I follow the issue.
I usually test through UI when I am doing Android Instrumentation tests - that way I don't mind asynchronous behavior.
If you test through e.g. ViewModel but still want to test on real device, in that case you will use something like
runTest
with
TestDispatcher
.
r
Rak
01/05/2022, 8:56 AM
The issue (now solved) is that i needed to mock the repository class, I achieved this with