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

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 override fun apply(p0: Statement, p1: Description): Statement