UnitTesting and Signalling ChildWorkflows


I have a few ChildWorkflows that receive signals. I can easily unit-test each such ChildWorkflow by giving them the signal with 1ms in RegisterDelayedCallback.

My issue comes in 2 places during unit-testing ChildWorkflows combined into one ParentWorkflow that require signalling:
1- I need to know the child-workflow-ID to send signal as the usual SignalWorkflow from UnitTest Environment is not enough. How can I get that ID reliably as it keeps changing?
2- Sending signals to multiple child workflows in UnitTest even with registerdDelayed only sends the first signal but the rest timeout even if I have the correct WorkflowIDs.

I checked all the samples including recovery and mutex_workflow where Signals are used in unit-tests but they don’t deal with children workflows.

I am not mocking Activities rather the resources they use are mocked.

How do you learn the child-workflow-ID in the non unit test scenario? You can add a query to the parent workflow that returns the child workflow ID.

Hi Maxim

I have not run those childWorkflows in non-unit-test cases yet but I am doing something like this from the activity
wfId := activity.GetInfo(ctx).WorkflowExecution.ID
runId := activity.GetInfo(ctx).WorkflowExecution.RunID

I didn’t think of query for childworkflow ID. I will give it a go.

You can implement a fake activity that assigns the workflow id to some variable in your unit test.

I will try that. This would be less work than adding a query to the workflow.