jQrgen
12/15/2024, 12:58 PMDispatchers.setMain(UnconfinedTestDispatcher)
the android tests time out and If i remove the line the JVM/Desktop tests fail and ask me to use Dispatcherrs.setMain(UconfinedTestDispatcher)
@BeforeTest
fun setUp() {
// This fails android but commenting it fails jvm because of the coroutines in BalanceViewModel
Dispatchers.setMain(UnconfinedTestDispatcher())
The flows in the viewModel looks like this:
private fun observeSelectedAccount()
{
accountJob?.cancel()
accountJob = viewModelScope.launch(dispatcher) {
selectedAccountUi2.onEach {
it?.let { account ->
setFiatBalance(account)
observeBalance(account)
}
}.launchIn(this)
}
}
agrosner
12/15/2024, 1:40 PMagrosner
12/15/2024, 1:48 PMjQrgen
12/16/2024, 7:04 PMprivate val testDispatcher = StandardTestDispatcher()
private val testScope = TestScope(testDispatcher)
agrosner
12/16/2024, 8:28 PM