I am trying to write some unit tests for my temporal code and am running into some odd behavior.
My temporal workflow runs some jobs according to a schedule and uses Workflow.sleep() to wait in between scheduled executions. I would like to write unit tests that can test that this behavior works correctly over a period of virtual months or years.
I have been following these examples for guidance on how to write these tests samples-java/src/test/java/io/temporal/samples at master · temporalio/samples-java · GitHub
I’ve been hitting issues when I sleep my TestEnv for too long. After much debug, I determined that the TestEnv sleeps instantaneously as long as the temporal workflow is also sleeping, but if the testEnv sleeps LONGER than the workflow sleeps, it blocks my test code.
For example: Let’s say my temporal workflow completes its work and sleeps 10 minutes. If I sleep the testEnv 10 minutes, then the testEnv sleep completes instantaneously. If I sleep 11 minutes, the 10 minutes sleeps instantaneously, and then my test blocks for the last 1 minute of sleep.
Is this the intended behavior? It has been very painful to write these tests because trying to sync up the testEnv sleep time with the worker sleep time exactly right creates needless complications.