UnitTest on init block in ViewModel don't stop in suspend function
I have this ViewModel with a standar init{} block that call a fetch Data function.
class HomeViewModel(
private val repository: CitiesRepository,
private val dispatcher: CoroutineDispatcher =
Dispatchers.IO
): ViewModel() {
private val _uiState = MutableStateFlow(HomeState())
val uiState = _uiState.asStateFlow()
init {
println("in init block") // Log
fetchData()
}
private fun fetchData() {
viewModelScope.launch(dispatcher) {
println("Corrutina iniciada") // Log...