Joan Colmenero
03/03/2020, 11:53 AMwithContext
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()
}
streetsofboston
03/03/2020, 12:55 PMJoan Colmenero
03/03/2020, 2:01 PMstreetsofboston
03/03/2020, 2:33 PM