Skip to content

//reactivestate-core-test/com.ensody.reactivestate.test/EventNotifierTest

EventNotifierTest

abstract class EventNotifierTest<E> : CoroutineTest

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.

Inheritors

ReactiveStateTest

Constructors

EventNotifierTest [common]
constructor()

Properties

Name Summary
attachedDisposables [common]
open override val attachedDisposables: DisposableGroup
eventNotifier [common]
abstract val eventNotifier: EventNotifier<E>
events [common]
abstract val events: E
eventsDispatcher [common]
open val eventsDispatcher: TestDispatcher
The dispatcher to use for handleEvents.
handleEventsInRunTest [common]
open val handleEventsInRunTest: Boolean = true
mainScope [common]
val ~~mainScope~~: CoroutineScope
testCoroutineDispatcher [common]
val ~~testCoroutineDispatcher~~: TestDispatcher
testCoroutineScope [common]
val ~~testCoroutineScope~~: TestScope
testDispatcher [common]
val testDispatcher: TestDispatcher
testScope [common]
val testScope: TestScope

Functions

Name Summary
collectFlow [common]
fun <T> TestScope.collectFlow(flow: Flow<T>, collector: suspend (T) -> Unit = {})
Collects a flow in the background.
dispose [common]
open override fun dispose()
enterCoroutineTest [common]
fun enterCoroutineTest()
exitCoroutineTest [common]
fun exitCoroutineTest()
handleEvents [common]
fun handleEvents()
runBlockingTest [common]
open fun ~~runBlockingTest~~(block: suspend TestScope.() -> Unit): TestResult
runTest [common]
open override fun runTest(block: suspend TestScope.() -> Unit): TestResult
In addition to running the test this also disposes the attachedDisposables (useful with collectFlow).