# Error while writing unit test for workflow

**URL:** <https://community.temporal.io/t/error-while-writing-unit-test-for-workflow/12676>\
**Category:** Community Support\
**Tags:** java-sdk\
**Created:** [June 28, 2024, 4:38am UTC](https://community.temporal.io/t/error-while-writing-unit-test-for-workflow/12676 "2024-06-28T04:38:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abhinav\_Verma](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/abhinav_verma/32/4887_2.png) [@Abhinav\_Verma](https://community.temporal.io/u/Abhinav_Verma)\
**Post date:** [June 28, 2024, 4:38am UTC](https://community.temporal.io/t/error-while-writing-unit-test-for-workflow/12676/1 "2024-06-28T04:38:13Z")

</div>

io.grpc.StatusRuntimeException: INVALID\_ARGUMENT: A valid StartToClose or ScheduleToCloseTimeout is not set on workflow task.  
at io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:271) ~[grpc-stub-1.54.1.jar:1.54.1]  
at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:252) ~[grpc-stub-1.54.1.jar:1.54.1]  
at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:165) ~[grpc-stub-1.54.1.jar:1.54.1]  
at io.temporal.api.workflowservice.v1.WorkflowServiceGrpc$WorkflowServiceBlockingStub.respondWorkflowTaskCompleted(WorkflowServiceGrpc.java:3924) ~[temporal-serviceclient-1.23.1.jar:?]  
at io.temporal.internal.worker.WorkflowWorker$TaskHandlerImpl.lambda$sendTaskCompleted$0(WorkflowWorker.java:483) ~[temporal-sdk-1.23.1.jar:?]  
at io.temporal.internal.retryer.GrpcSyncRetryer.retry(GrpcSyncRetryer.java:69) ~[temporal-serviceclient-1.23.1.jar:?]  
at io.temporal.internal.retryer.GrpcRetryer.retryWithResult(GrpcRetryer.java:60) ~[temporal-serviceclient-1.23.1.jar:?]  
at io.temporal.internal.worker.WorkflowWorker$TaskHandlerImpl.sendTaskCompleted(WorkflowWorker.java:478) ~[temporal-sdk-1.23.1.jar:?]  
at io.temporal.internal.worker.WorkflowWorker$TaskHandlerImpl.handle(WorkflowWorker.java:350) ~[temporal-sdk-1.23.1.jar:?]  
at io.temporal.internal.worker.WorkflowWorker$TaskHandlerImpl.handle(WorkflowWorker.java:278) ~[temporal-sdk-1.23.1.jar:?]  
at io.temporal.internal.worker.PollTaskExecutor.lambda$process$0(PollTaskExecutor.java:105) ~[temporal-sdk-1.23.1.jar:?]  
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]  
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]  
at java.base/java.lang.Thread.run(Thread.java:840) [?:?]

2024-06-28 10:05:49,787 21079 [Workflow Executor taskQueue=“WorkflowTest-Test Replace Artefact WorkFlow Successful Scenario-[engine:junit-jupiter]/[class:in.zeta.aether.harmonix.workflow.impl.ReplaceArtefactWorkFlowImplTest]/[method:replaceArtefactWorkFlowImpl\_Success(io.temporal.testing.TestWorkflowEnvironment, io.temporal.worker.Worker, in.zeta.aether.harmonix.workflow.ReplaceArtefactWorkFlow)]”, namespace=“UnitTest”: 1] WARN [i.t.i.w.WorkflowWorker] {Namespace=UnitTest, RunId=23c6d78c-8ef7-4e40-bd62-9b8236c1622c, TaskQueue=WorkflowTest-Test Replace Artefact WorkFlow Successful Scenario-[engine:junit-jupiter]/[class:in.zeta.aether.harmonix.workflow.impl.ReplaceArtefactWorkFlowImplTest]/[method:replaceArtefactWorkFlowImpl\_Success(io.temporal.testing.TestWorkflowEnvironment, io.temporal.worker.Worker, in.zeta.aether.harmonix.workflow.ReplaceArtefactWorkFlow)], WorkflowId=4b43d2e0-d0a6-48d2-983b-9ba3601aa118, WorkflowType=ReplaceArtefactWorkFlow, appResourceId=abhinav.ve@dev, clusterName=default, container=unknown-container, deployment=unknown-deployment, node=unknown-node, pod=dev, service=unknown-service} - Failure while reporting workflow progress to the server. If seen continuously the workflow might be stuck. WorkflowId=4b43d2e0-d0a6-48d2-983b-9ba3601aa118, RunId=23c6d78c-8ef7-4e40-bd62-9b8236c1622c, startedEventId=3 io.grpc.StatusRuntimeException: INVALID\_ARGUMENT: A valid StartToClose or ScheduleToCloseTimeout is not set on workflow task.  
at io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:271)  
at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:252)  
at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:165)  
at io.temporal.api.workflowservice.v1.WorkflowServiceGrpc$WorkflowServiceBlockingStub.respondWorkflowTaskCompleted(WorkflowServiceGrpc.java:3924)  
at io.temporal.internal.worker.WorkflowWorker$TaskHandlerImpl.lambda$sendTaskCompleted$0(WorkflowWorker.java:483)  
at io.temporal.internal.retryer.GrpcSyncRetryer.retry(GrpcSyncRetryer.java:69)  
at io.temporal.internal.retryer.GrpcRetryer.retryWithResult(GrpcRetryer.java:60)  
at io.temporal.internal.worker.WorkflowWorker$TaskHandlerImpl.sendTaskCompleted(WorkflowWorker.java:478)  
at io.temporal.internal.worker.WorkflowWorker$TaskHandlerImpl.handle(WorkflowWorker.java:350)  
at io.temporal.internal.worker.WorkflowWorker$TaskHandlerImpl.handle(WorkflowWorker.java:278)  
at io.temporal.internal.worker.PollTaskExecutor.lambda$process$0(PollTaskExecutor.java:105)  
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)  
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)  
at java.base/java.lang.Thread.run(Thread.java:840)  
Receiving above Error while writing Unit Test for my 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:** [June 28, 2024, 8:00pm UTC](https://community.temporal.io/t/error-while-writing-unit-test-for-workflow/12676/2 "2024-06-28T20:00:11Z")

</div>

> A valid StartToClose or ScheduleToCloseTimeout is not set on workflow task.

It means that one of the activities doesn’t specify one of the required timeouts.

---

<div class="post-metadata">

**Author:** ![Abhinav\_Verma](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/abhinav_verma/32/4887_2.png) [@Abhinav\_Verma](https://community.temporal.io/u/Abhinav_Verma)\
**Post date:** [June 29, 2024, 8:33am UTC](https://community.temporal.io/t/error-while-writing-unit-test-for-workflow/12676/3 "2024-06-29T08:33:36Z")

</div>

```
@RegisterExtension
public static final TestWorkflowExtension testWorkflowExtension =
        TestWorkflowExtension.newBuilder()
                .setWorkflowTypes(ReplaceArtefactWorkFlowImpl.class)
                .setDoNotStart(true)
                .build();
    ArtefactGatewayActivity artefactGatewayActivity = Mockito.mock(ArtefactGatewayActivity.class);
    BundleHubActivity bundleHubActivity = Mockito.mock(BundleHubActivity.class);

```

I’m using like above to mock my activites. I’m now specifiying the StartToClose or ScheduleToCloseTimeout by mocking the workflow config class.FYI i have workflow config file in which i specify above properties  
WorkflowConfig workflowConfig = Mockito.mock(WorkflowConfig.class);  
Mockito.when(workflowConfig.getActivityStartToCloseTimeoutMinutes()).thenReturn(20L);  
Mockito.when(workflowConfig.getActivityScheduleToCloseTimeoutMinutes()).thenReturn(20L);  
Mockito.when(workflowConfig.getWorkFlowExecutionTimeoutMinutes()).thenReturn(60L);  
After doing the above things  
I’m receiving the following error when i’m mocking one of my activities call.  
Method threw ‘io.temporal.internal.sync.DestroyWorkflowThreadError’ exception. Also the acitivity is showing Method threw ‘java.lang.IllegalArgumentException’ exception. Cannot evaluate jdk.proxy2.$Proxy90.toString(). This is i’m receiving on debugger mode. Please help here.

Also my activity calls are in different class than the workflow one. For example if there are two classes A and B then class A is my WorkflowImpl class and in class B I have a method in which my activity calls are present. So i’m calling that method of class B in class A. Can this be a cause of problem ?

---

<div class="post-metadata">

**Author:** ![Abhinav\_Verma](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/abhinav_verma/32/4887_2.png) [@Abhinav\_Verma](https://community.temporal.io/u/Abhinav_Verma)\
**Post date:** [June 29, 2024, 2:08pm UTC](https://community.temporal.io/t/error-while-writing-unit-test-for-workflow/12676/4 "2024-06-29T14:08:35Z")

</div>

Got this solved. I was missing the one mock.
