Would you recommend testing cancellation or termination of workflows? It looks like this would only be possible for activities since those can be mocked, but not so much for timers (like Sleep).
Perhaps, even broader - what do you think would be valuable unit tests for a fairly simple workflow?
Ex workflow:
Execute activity A (has retries, 1 non-retryable application error)
Sleep 2 days
Execute activity B (has retries, all errors retriable)
We do test termination as part of the Temporal service release. It doesn’t make sense to test termination from the application point of view as it doesn’t give any control to the application. It is like asking to test an application code when it receives “kill -9”.
You absolutely want to test workflow cancellation as it is expected that workflow code handles a cancellation request according to its business logic. You don’t need to mock Sleep to test cancellation. Canceling a workflow while it is sleeping is going to fail the Sleep call with CanceledError.
Perhaps, even broader - what do you think would be valuable unit tests for a fairly simple workflow?
Ex workflow:
Execute activity A (has retries, 1 non-retryable application error)
Sleep 2 days
Execute activity B (has retries, all errors retriable)