# UnitTesting and Signalling ChildWorkflows

**URL:** <https://community.temporal.io/t/unittesting-and-signalling-childworkflows/2165>\
**Category:** Community Support\
**Tags:** go-sdk\
**Created:** [May 18, 2021, 5:11pm UTC](https://community.temporal.io/t/unittesting-and-signalling-childworkflows/2165 "2021-05-18T17:11:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![faizan](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/faizan/32/952_2.png) [@faizan](https://community.temporal.io/u/faizan)\
**Post date:** [May 18, 2021, 5:11pm UTC](https://community.temporal.io/t/unittesting-and-signalling-childworkflows/2165/1 "2021-05-18T17:11:49Z")

</div>

Hi

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.

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

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [May 18, 2021, 5:38pm UTC](https://community.temporal.io/t/unittesting-and-signalling-childworkflows/2165/2 "2021-05-18T17:38:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![faizan](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/faizan/32/952_2.png) [@faizan](https://community.temporal.io/u/faizan)\
**Post date:** [May 18, 2021, 5:53pm UTC](https://community.temporal.io/t/unittesting-and-signalling-childworkflows/2165/3 "2021-05-18T17:53:54Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [May 18, 2021, 5:55pm UTC](https://community.temporal.io/t/unittesting-and-signalling-childworkflows/2165/4 "2021-05-18T17:55:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![faizan](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/faizan/32/952_2.png) [@faizan](https://community.temporal.io/u/faizan)\
**Post date:** [May 18, 2021, 8:26pm UTC](https://community.temporal.io/t/unittesting-and-signalling-childworkflows/2165/5 "2021-05-18T20:26:59Z")

</div>

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

Thanks.
