Coroutines - unit testing viewModelScope.launch methods
问题 I am writing unit tests for my viewModel, but having trouble executing the tests. The runBlocking { ... } block doesn't actually wait for the code inside to finish, which is surprising to me. The test fails because result is null . Why doesn't runBlocking { ... } run the launch block inside the ViewModel in blocking fashion? I know if I convert it to a async method that returns a Deferred object, then I can get the object by calling await() , or I can return a Job and call join() . But , I'd