Testing Activities

Hi guys,
I’m trying to use a test suite for verifying the workflows and activities input and output. Regarding Activities I was able to verify inputs by using method env.onActivity but I was not able to test output. Is it possible to call an activity, really execute it and test the related result? I did not find an example in the go ask sample repository regarding this.
Could you suggest me an approach?

Great thanks for your time
Marco

Use TestActivityEnvironment for activity testing. It is created through WorkflowTestSuite.NewActivityEnvironment.

Great thanks Maxim,
I successfully used the suggested method and all works fine.
A last question about the topic: could you confirm that the test suite requires the temporal server up and running and that there is no possibility to test and mock without it?
Thanks in advance.
Marco

could you confirm that the test suite requires the temporal server up and running and that there is no possibility to test and mock without it?

Not confirming.

The unit testing framework does not need the temporal service up and running.

It was my fault. I wrongly run the worker during test. I adjusted code and all works fine.

Thanks again for your support
Regards
Marco

1 Like