ReactiveStateTest

Base class for unit testing an EventNotifier.

You have to override the eventNotifier and events attributes. Usually, events will be a mock.

By default this handles events in runTest. You can disable this by overriding handleEventsInRunTest to false. In that case you have to explicitly call handleEvents in each test.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
Link copied to clipboard
open override val eventNotifier: EventNotifier<E>
Link copied to clipboard
abstract val events: E
Link copied to clipboard
open val eventsDispatcher: TestDispatcher

The dispatcher to use for handleEvents.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val testDispatcher: TestDispatcher
Link copied to clipboard
val testScope: TestScope

Functions

Link copied to clipboard
fun <T> TestScope.collectFlow(flow: Flow<T>, collector: suspend (T) -> Unit = {})

Collects a flow in the background.

Link copied to clipboard
open override fun dispose()
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override fun runTest(block: suspend TestScope.() -> Unit): TestResult

In addition to running the test this also disposes the attachedDisposables (useful with collectFlow).