Finding the Time Elapsed in Testing a Workflow that has workflow.Sleep

Hello,

I am trying to test a workflow that sleeps for 2 different time periods depending on a certain condition using workflow.Sleep. I know that temporal internally advances the time to avoid the sleep time when testing. Is there a way to access the sleep time that was elapsed in the tests so that to validate that the workflow sleeps for the proper amount of time for a given condition?

Thanks,
Mark

I would have to test to confirm, but I believe you can use TestWorkflowEnvironment.Now() to get the mock clock which has the start time + the skipped durations (start time can be set via TestWorkflowEnvironment.SetStartTime).

1 Like

Use TestEnvironment.currentTimeMillis to get the current time of the unit test.

1 Like