headlessIntegrationTest

fun <PropsT, OutputT, RenderingT> Workflow<PropsT, OutputT, RenderingT>.headlessIntegrationTest(props: StateFlow<PropsT>, coroutineContext: CoroutineContext = UnconfinedTestDispatcher(), interceptors: List<WorkflowInterceptor> = emptyList(), runtimeConfig: RuntimeConfig = RuntimeConfigOptions.DEFAULT_CONFIG, onOutput: suspend (OutputT) -> Unit = {}, testTimeout: Long = WORKFLOW_TEST_DEFAULT_TIMEOUT_MS, testCase: suspend WorkflowTurbine<RenderingT>.() -> Unit)(source)

This is a test harness to run integration tests for a Workflow tree. The parameters passed here are the same as those to start a Workflow runtime with renderWorkflowIn except for ignoring state persistence as that is not needed for this style of test.

The coroutineContext rather than a CoroutineScope is passed so that this harness handles the scope for the Workflow runtime for you but you can still specify context for it.

A testTimeout may be specified to override the default WORKFLOW_TEST_DEFAULT_TIMEOUT_MS for any particular test. This is the max amount of time the test could spend waiting on a rendering.

This will start the Workflow runtime (with params as passed) rooted at whatever Workflow it is called on and then create a WorkflowTurbine for its renderings and run testCase on that. testCase can thus drive the test scenario and assert against renderings.


fun <OutputT, RenderingT> Workflow<Unit, OutputT, RenderingT>.headlessIntegrationTest(coroutineContext: CoroutineContext = UnconfinedTestDispatcher(), interceptors: List<WorkflowInterceptor> = emptyList(), runtimeConfig: RuntimeConfig = RuntimeConfigOptions.DEFAULT_CONFIG, onOutput: suspend (OutputT) -> Unit = {}, testTimeout: Long = WORKFLOW_TEST_DEFAULT_TIMEOUT_MS, testCase: suspend WorkflowTurbine<RenderingT>.() -> Unit)(source)

Version of headlessIntegrationTest that does not require props. For Workflows that have Unit props type.