Mocking Workflow.getWorkflowExecution method

Hello! I have a Parent workflow with a child workflow that runs asynchronous, like:

 // some code
ChildWF child = Workflow.newChildWorkflowStub(ChildWF.class,
        Async.procedure(child::childWFMethod, param);
        try {
        	Promise<WorkflowExecution> childPromise = Workflow.getWorkflowExecution(child);
        } catch (ChildWorkflowFailure ex) {
            if (ex.getCause() instanceof WorkflowExecutionAlreadyStarted) {
        } catch (Exception ex) {
// end parent wf

Then I want to test the failure of the child wf, so in my test I tried to mock the Workflow.getWorkflowExecution(child) to throw an exception, but I am not able to make it work.

// previous mocked activities definition, TestWorkflowExtension, ActivityStubFactory and so...

		worker.registerWorkflowImplementationFactory(ParentWF.class, () -> {
            var workflow = new ParentWFImpl(params);
            this.factory.inject(workflow, workflow.getClass());
            return workflow;
		worker.registerWorkflowImplementationFactory(ChildWF.class, () -> {
			var childworkflow = mock(ChildWF.class);
            this.factory.inject(childworkflow, ChildWF.class);
            return childworkflow;
		var parentWorkflow = testEnv.getWorkflowClient().newWorkflowStub(ParentWF.class,
		RuntimeException runtimeException = new RuntimeException("test error");
		try (MockedStatic<Workflow> wf = Mockito.mockStatic(Workflow.class)) {
			wf.when(() -> Workflow.getWorkflowExecution(childWF)).thenThrow(runtimeException);
			Assertions.assertThatExceptionOfType(RuntimeException.class).isThrownBy(() -> Workflow.getWorkflowExecution(childWF));
		Assertions.assertThatCode(() -> parentWorkflow.parentWFMethod(someParam)).doesNotThrowAnyException();

When I run the test, I have it green, like succesfull, but when I launch the coverage or debug it, I see that never enter in the exceptions part, that is what I want to test.
Is there something I am missing, thanks.

Then I want to test the failure of the child wf

Are you specifically trying to test possible failures of starting the child execution due to workflow id
reuse policy? You could in your test just start a workflow execution with same workflow id as the child this parent is trying to start async. Then make sure parent handles ChildWorkflowFailure (which should have cause WorkflowExecutionAlreadyStarted as you correctly state in code).

Yes I tried that also, but cant get the error I want. I did something like:

//something previous
var childWF = testEnv.getWorkflowClient().newWorkflowStub(ChildWF.class,

var workflow = testEnv.getWorkflowClient().newWorkflowStub(ParentWF.class,


Mockito.verify(this.ChildWFActivities, Mockito.times(1)).childWFActivityMethod(param);

And I have The workflow id mocked so every childwf that started in the parent, will have the same id as in the test.
And temporal logs show that the child is executed more than once. The first time because of the direct execution in the test, and then one more time, with same workflow Id, when the parent creates.