https://kotlinlang.org logo
#coroutines
Title
# coroutines
m

mayojava

03/28/2019, 11:46 AM
What's the recommended way for swapping Default and IO schedulers for UI tests on Android
s

streetsofboston

03/28/2019, 11:52 AM
Structure your code in such a way that you inject the Dispatchers into your code (possibly use dependency injection (DI) framework). No swapping required, just change your DI a bit.
👍 1
m

mayojava

03/28/2019, 11:56 AM
Was thinking about how to achieve something similar to RxJavaPlugins
i

ienoobong

03/28/2019, 12:13 PM
Copy code
@Before
    fun setup() {
        Dispatchers.setMain(Dispatchers.Unconfined)
    }

    @After
    fun tearDown() {
        Dispatchers.resetMain()
    }
s

streetsofboston

03/28/2019, 1:42 PM
^^^ That is only for the Main dispatcher. Not sure if you can do the same for the IO and Default.
3 Views