//reactivestate-core-test/com.ensody.reactivestate.test/ReactiveStateTest
ReactiveStateTest¶
[common]\ abstract class ReactiveStateTest<E : ErrorEvents> : EventNotifierTest<E>
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¶
ReactiveStateTest | [common] constructor() |
Properties¶
Name | Summary |
---|---|
attachedDisposables | [common] open override val attachedDisposables: DisposableGroup |
eventNotifier | [common] open override 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 |
mainScope | [common] val ~~mainScope~~: CoroutineScope |
reactiveState | [common] abstract val reactiveState: ReactiveState<E> |
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). |