test

suspend fun <STATE : Any, SIDE_EFFECT : Any, CONTAINER_HOST : ContainerHost<STATE, SIDE_EFFECT>> CONTAINER_HOST.test(testScope: TestScope, initialState: STATE? = null, timeout: Duration? = null, settings: TestSettings = TestSettings(), validate: suspend OrbitTestContext<STATE, SIDE_EFFECT, CONTAINER_HOST>.() -> Unit)

Run tests on your ContainerHost. This mode uses a real Orbit container, but the container's CoroutineDispatcher is set to the TestScope's background dispatcher.

Typically this is the scope defined by kotlin's runTest, but you are free to provide your own TestScope. This is useful if you wish to e.g. control virtual time to avoid delay skipping.

During a test, all of the emitted states and side effects must be consumed - otherwise the test fails. See OrbitTestContext.

Parameters

testScope

The scope in which the Container will run.

initialState

The state to initialize the test container with. Omit this parameter to use the real initial state of the container.

settings

Use this to set overrides for some of the container's RealSettings for this test.

validate

Perform your test within this block. See OrbitTestContext.