MainDispatcherRule
class MainDispatcherRule constructor(val testDispatcher: TestDispatcher = UnconfinedTestDispatcher()) : TestWatcher
A test rule that replaces the Dispatchers.Main with another CoroutineDispatcher. See here for more information
Usage:
class TestClass {
@get:Rule
val dispatcherRule = MainDispatcherRule()
}
Content copied to clipboard
Do not use this for instrumented tests
Parameters
testDispatcher
dispatcher that will be used for Dispatchers.Main