BaseUIThreadTest

This class allows a test block to be run on the UI thread inside a custom context that is also created in the UI Thread using a configuration.

While normally iOS tests already run on the UI thread, this prevents the Main dispatcher from working as long as that Thread is blocked, so this class is mostly used in conjunction with the com.splendo.kaluga.test.base.mainBackground entry point.

It is useful for Kotlin Native classes that only work when created on the UI thread, as it eases dealing with immutability and allows a shared context.

Inheritors

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
interface TestContext

Properties

Link copied to clipboard
abstract val createTestContextWithConfiguration: suspend (configuration: Configuration, scope: CoroutineScope) -> Context

Creates the TestContext based on Configuration and CoroutineScope

Functions

Link copied to clipboard
expect open fun afterTest()
Link copied to clipboard
expect open fun beforeTest()
Link copied to clipboard
fun testOnUIThread(configuration: Configuration, cancelScopeAfterTest: Boolean = false, block: suspend Context.() -> Unit)

Run your test block on the UI thread and inside the TestContext.