Test activity - Timeout trying execute activity task task_token: "test-task-token"

I’m trying to test my activity which polls info from 2 servers, both are mocked with Mockito.
The test is running perfectly fine when the duration of the poll is 4000ms.

once we increase the duration to 10 seconds for example we are facing some exceptions:

java.lang.RuntimeException: java.util.concurrent.TimeoutException

[workflow-root] Timeout trying execute activity task task_token: “test-task-token”

out test is something like:

 testEnv = TestActivityEnvironment.newInstance(TestEnvironmentOptions.newBuilder()

void PollingTest_Success_Case() {
testEnv.registerActivitiesImplementations(new MonitoringImpl(firstMockService, secondMockServer));
Monitoring activity = testEnv.newActivityStub(Monitoring.class);
var result = activity.monitor(payload);

the issue is that after 10 seconds there is a timeout,
If for example, I change it to 6 seconds,
it will make 1 and a half iterations.
it seems like it fails when we try to heartbeat the activity


log shows:

workflow_execution {
workflow_id: “test-workflow-id”
run_id: “1a2697ab-83a6-4f06-bc4d-841217a3a81d”
activity_type {
name: “monitor”
activity_id: “1”
input {
payloads {
metadata {
key: “encoding”
value: “json/plain”
data: “{someData}”
scheduled_time {
seconds: 1678277605
nanos: 808000000
started_time {
seconds: 1678277605
nanos: 810000000
schedule_to_close_timeout {
seconds: 86400
start_to_close_timeout {
heartbeat_timeout {
seconds: 1

Thank you!