Hello! Thank you very much for the very nice framework!
I am writing the unit tests for the workflows to be used in our company. We use go-sdk for managing the workflows. And I have some questions about the unit tests. In fact, I have created a folder in my repo for temporal experiments in order to demonstrate what I mean.
Why do we need to register an activity for the workflow to be tested?
env.OnActivityfunction is expected to provide a mock for the activity so mentioning the name as the string seems to be enough. In fact, the registered activity should not be called, it is just dummy. If we do not register the activity we have the panic
test panicked: activity "Activity1" is not registered with the TestWorkflowEnvironment
How can we ensure that a given activity is not called for the workflow execution?
env.OnActivity().Times(0)result in failing the test despite they are not called.
How can we create the workflow context instance?
Background()is hidden in the internal package. I need it in order to test the custom workflow context propagators. We cannot test it with the workflow test suite because of https://github.com/temporalio/go-sdk/issues/190 So I am trying to make the workflow context, execute the loop
ExtractToWorkflowusing a mock HeaderWriter+HeaderReader. Then I check the resulting workflow context. Since there is no way to create the workflow context explicitly, I need to run a dummy test workflow to get the workflow context from there. And the test looks rather ugly.