# Is it possible to mock Workflow.getInfo() method call when writing test case?

**URL:** <https://community.temporal.io/t/is-it-possible-to-mock-workflow-getinfo-method-call-when-writing-test-case/2877>\
**Category:** Community Support\
**Tags:** java-sdk\
**Created:** [September 7, 2021, 8:26pm UTC](https://community.temporal.io/t/is-it-possible-to-mock-workflow-getinfo-method-call-when-writing-test-case/2877 "2021-09-07T20:26:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vikas\_NS](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/vikas_ns/32/1210_2.png) [@Vikas\_NS](https://community.temporal.io/u/Vikas_NS)\
**Post date:** [September 7, 2021, 8:26pm UTC](https://community.temporal.io/t/is-it-possible-to-mock-workflow-getinfo-method-call-when-writing-test-case/2877/1 "2021-09-07T20:26:37Z")

</div>

I’m writing unit test case for a child workflow.  
In the childworkflow, we fetch the parent workflow id by calling Workflow.getInfo().getParentWorkflowId().

As its a unit test, I would be directly running the chlidWorkflow and there won’t be any ParentWorkflow.  
Because of this Workflow.getInfo().getParentWorkflowId() will return null.

I want to mock Workflow.getInfo() saw that I can return a custom WorkflowInfo object with parent workflow id.

Is this possible?

I tried with Mockito, looks like it doens’t have any impact.

Or is it possible to set Parent workflow ID manually before starting a child workflow ?

---

<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:** [September 7, 2021, 9:26pm UTC](https://community.temporal.io/t/is-it-possible-to-mock-workflow-getinfo-method-call-when-writing-test-case/2877/2 "2021-09-07T21:26:16Z")

</div>

I would recommend creating a parent workflow just for this unit test.

---

<div class="post-metadata">

**Author:** ![Manoj\_Sugumaran](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/manoj_sugumaran/32/2123_2.png) [@Manoj\_Sugumaran](https://community.temporal.io/u/Manoj_Sugumaran)\
**Post date:** [May 27, 2022, 1:16pm UTC](https://community.temporal.io/t/is-it-possible-to-mock-workflow-getinfo-method-call-when-writing-test-case/2877/3 "2022-05-27T13:16:31Z")

</div>

I am having a similar problem too. How would I create a parent workflow in the unit test

---

<div class="post-metadata">

**Author:** ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)\
**Post date:** [May 27, 2022, 2:26pm UTC](https://community.temporal.io/t/is-it-possible-to-mock-workflow-getinfo-method-call-when-writing-test-case/2877/5 "2022-05-27T14:26:06Z")

</div>

@Manoj_Sugumaran  
you can create a test parent workflow (interface and impl) that invokes your child workflow thats under test and register both this test parent and your child workflow with the test env. Then start this test parent workflow in your test.

Let us know if you would need a sample for this.
