Replies: 1 comment 1 reply
-
Looking at your ViewModel, it appears you are already passing in a As for the test itself, all test dispatchers should be sharing the same scheduler. According to https://developer.android.com/kotlin/coroutines/test#testdispatchers
Hence, I'd update val vm = MainViewModel(
dispatcher = UnconfinedTestDispatcher(TestCoroutineScheduler())
) to val vm = MainViewModel(
dispatcher = UnconfinedTestDispatcher(testScheduler)
) Where Also, make sure to update to the latest version of Turbine, since there have been some significant changes and fixes lately. Not sure if your tests will suddenly start passing with these changes, but at least you can troubleshoot from there. |
Beta Was this translation helpful? Give feedback.
-
Hi, I am wondering how can I test the debounce with turbine.
I have the following ViewModel:
Here is the test:
where CoroutineTestRule:
My test is getting timed out, not sure what am I doing wrong here?
While debugging the breakpoint inside the collectLatest block is never triggered.
If I remove the debounce or set it to 0 the test passes.
Versions:
kotlin: 1.5.31
coroutines: 1.6.1
turbine: 0.8.0
Beta Was this translation helpful? Give feedback.
All reactions