MainDispatcherRule

class MainDispatcherRule(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()
}

Do not use this for instrumented tests

Parameters

testDispatcher

dispatcher that will be used for Dispatchers.Main

Constructors

Link copied to clipboard
constructor(testDispatcher: TestDispatcher = UnconfinedTestDispatcher())

Properties

Link copied to clipboard
val testDispatcher: TestDispatcher

Functions

Link copied to clipboard
open fun apply(base: Statement?, description: Description?): Statement?