@@ -49,58 +49,6 @@ import kotlin.time.Duration.Companion.milliseconds
4949 * The default [RuntimeConfig] will be the one specified via [JvmTestRuntimeConfigTools].
5050 */
5151@OptIn(ExperimentalCoroutinesApi ::class )
52- public fun <PropsT , OutputT , RenderingT > Workflow <PropsT , OutputT , RenderingT >.renderForTest (
53- props : StateFlow <PropsT >,
54- testParams : WorkflowTestParams <Nothing > = WorkflowTestParams (),
55- coroutineContext : CoroutineContext = UnconfinedTestDispatcher (),
56- interceptors : List <WorkflowInterceptor > = emptyList(),
57- onOutput : suspend (OutputT ) -> Unit = {},
58- testTimeout : Long = WORKFLOW_TEST_DEFAULT_TIMEOUT_MS ,
59- testCase : suspend WorkflowTurbine <RenderingT , OutputT >.() -> Unit
60- ) = asStatefulWorkflow().renderForTest(
61- props,
62- testParams,
63- coroutineContext,
64- onOutput,
65- testTimeout,
66- testCase
67- )
68-
69- /* *
70- * Version of [renderForTest] that does not require props. For Workflows that have [Unit]
71- * props type.
72- */
73- @OptIn(ExperimentalCoroutinesApi ::class )
74- public fun <OutputT , RenderingT > Workflow <Unit , OutputT , RenderingT >.renderForTest (
75- coroutineContext : CoroutineContext = UnconfinedTestDispatcher (),
76- testParams : WorkflowTestParams <Nothing > = WorkflowTestParams (),
77- interceptors : List <WorkflowInterceptor > = emptyList(),
78- onOutput : suspend (OutputT ) -> Unit = {},
79- testTimeout : Long = WORKFLOW_TEST_DEFAULT_TIMEOUT_MS ,
80- testCase : suspend WorkflowTurbine <RenderingT , OutputT >.() -> Unit
81- ): Unit = renderForTest(
82- props = MutableStateFlow (Unit ).asStateFlow(),
83- testParams = testParams,
84- coroutineContext = coroutineContext,
85- interceptors = interceptors,
86- onOutput = onOutput,
87- testTimeout = testTimeout,
88- testCase = testCase
89- )
90-
91- /* *
92- * Version of [renderForTest] for a [StatefulWorkflow]
93- * that accepts [WorkflowTestParams] for configuring the test,
94- * including starting from a specific state or snapshot.
95- *
96- * @param props StateFlow of props to send to the workflow.
97- * @param testParams Test configuration parameters. See [WorkflowTestParams] for details.
98- * @param coroutineContext Optional [CoroutineContext] to use for the test.
99- * @param onOutput Callback for workflow outputs.
100- * @param testTimeout Maximum time to wait for workflow operations in milliseconds.
101- * @param testCase The test code to run with access to the [WorkflowTurbine].
102- */
103- @OptIn(ExperimentalCoroutinesApi ::class )
10452public fun <PropsT , StateT , OutputT , RenderingT >
10553 StatefulWorkflow <PropsT , StateT , OutputT , RenderingT >.renderForTest (
10654 props : StateFlow <PropsT >,
@@ -189,9 +137,8 @@ public fun <PropsT, StateT, OutputT, RenderingT>
189137}
190138
191139/* *
192- * Version of [renderForTest] for a [StatefulWorkflow]
193- * that accepts [WorkflowTestParams] and doesn't require props.
194- * For Workflows that have [Unit] props type.
140+ * Version of [renderForTest] that does not require props. For [StatefulWorkflow]s that have [Unit]
141+ * props type.
195142 */
196143@OptIn(ExperimentalCoroutinesApi ::class )
197144public fun <StateT , OutputT , RenderingT >
@@ -210,6 +157,59 @@ public fun <StateT, OutputT, RenderingT>
210157 testCase = testCase
211158)
212159
160+ /* *
161+ * Version of [renderForTest] for any [Workflow]
162+ * that accepts [WorkflowTestParams] for configuring the test,
163+ * including starting from a specific state or snapshot.
164+ *
165+ * @param props StateFlow of props to send to the workflow.
166+ * @param testParams Test configuration parameters. See [WorkflowTestParams] for details.
167+ * @param coroutineContext Optional [CoroutineContext] to use for the test.
168+ * @param onOutput Callback for workflow outputs.
169+ * @param testTimeout Maximum time to wait for workflow operations in milliseconds.
170+ * @param testCase The test code to run with access to the [WorkflowTurbine].
171+ */
172+ @OptIn(ExperimentalCoroutinesApi ::class )
173+ public fun <PropsT , OutputT , RenderingT > Workflow <PropsT , OutputT , RenderingT >.renderForTestForStartWith (
174+ props : StateFlow <PropsT >,
175+ testParams : WorkflowTestParams <Nothing > = WorkflowTestParams (),
176+ coroutineContext : CoroutineContext = UnconfinedTestDispatcher (),
177+ interceptors : List <WorkflowInterceptor > = emptyList(),
178+ onOutput : suspend (OutputT ) -> Unit = {},
179+ testTimeout : Long = WORKFLOW_TEST_DEFAULT_TIMEOUT_MS ,
180+ testCase : suspend WorkflowTurbine <RenderingT , OutputT >.() -> Unit
181+ ) = asStatefulWorkflow().renderForTest(
182+ props,
183+ testParams,
184+ coroutineContext,
185+ onOutput,
186+ testTimeout,
187+ testCase
188+ )
189+
190+ /* *
191+ * Version of [renderForTest] for any [Workflow]
192+ * that accepts [WorkflowTestParams] and doesn't require props.
193+ * For Workflows that have [Unit] props type.
194+ */
195+ @OptIn(ExperimentalCoroutinesApi ::class )
196+ public fun <OutputT , RenderingT > Workflow <Unit , OutputT , RenderingT >.renderForTestForStartWith (
197+ coroutineContext : CoroutineContext = UnconfinedTestDispatcher (),
198+ testParams : WorkflowTestParams <Nothing > = WorkflowTestParams (),
199+ interceptors : List <WorkflowInterceptor > = emptyList(),
200+ onOutput : suspend (OutputT ) -> Unit = {},
201+ testTimeout : Long = WORKFLOW_TEST_DEFAULT_TIMEOUT_MS ,
202+ testCase : suspend WorkflowTurbine <RenderingT , OutputT >.() -> Unit
203+ ): Unit = renderForTestForStartWith(
204+ props = MutableStateFlow (Unit ).asStateFlow(),
205+ testParams = testParams,
206+ coroutineContext = coroutineContext,
207+ interceptors = interceptors,
208+ onOutput = onOutput,
209+ testTimeout = testTimeout,
210+ testCase = testCase
211+ )
212+
213213/* *
214214 * Convenience function to test a workflow starting from a specific state.
215215 *
0 commit comments