I'm trying to remove the
withContext
from my viewModel and I'm planning to put it on the
usecase
/
repository
something like this
launch{
updateView()
withContext(<http://Dispatchers.IO|Dispatchers.IO>){
doLogin(username,password)
}
updateView()
}
This is how I'm doing it now ^
Then if I want to remove the
withContext(<http://Dispatchers.IO|Dispatchers.IO>)
I can do it like this
suspend fun doLogin(usernarme: String, password: String) = <http://Dispatchers.IO|Dispatchers.IO> { repo.doLogin(username,password)... }
So, is there any way to test it correctly?
I'm using
mockK
so, I know with
coEvery
is going to work, but is it safe to do not put
Dispatchers.Uncofined
for testing purposes?
Also do you think it's a good idea to do not change context on viewModel and then just do this
launch {
updateView()
doLogin(username,password)
updateView()
}