You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Cool library, and thank you for your hard work on it! I'm trying to help improve it through this feedback, and would be willing to open a PR if there's guidance provided on desirable compromises or solutions.
The way that Temporal::Workflowrescues StandardError makes catching exceptions in tests hard.
Take this spec as an example:
$global_var =0classHelloWorldWorkflow < Temporal::Workflowdefexecute(arg1,required_key:)
$global_var += 1nilendenddescribeHelloWorldWorkflowdoit"doesn't allow exceptions to surface very easily"doTemporal::Testing.local!doTemporal.start_workflow(HelloWorldWorkflow,"foo",required_key: "bar")expect($global_var).toeq(1)Temporal.start_workflow(HelloWorldWorkflow,"foo")# incorrect argumentsexpect($global_var).toeq(2)endendend
The result is:
expected: 2
got: 1
(compared using ==)
Yes, I can see in the logs that an exception is logged, but I feel like in tests raising exceptions should be the rule. Any number of things can break downstream within a workflow, and sometimes (when not directly testing the unit that is the workflow) it's useful to call a thing, and not have to make an assertion that it didn't log an exception -- if that makes sense. Rescuing StandardError is heavy handed in the tests, because allowing those to raise is way more useful in identifying any issues.
To address this I've wrapped the base class with my own, so I can re-raise the exception in a way that Temporal doesn't try to handle. I'm wondering if Temporal::Testing should take this into consideration and not rescue any exceptions when executing the workflow locally in tests.
Cool library, and thank you for your hard work on it! I'm trying to help improve it through this feedback, and would be willing to open a PR if there's guidance provided on desirable compromises or solutions.
The way that
Temporal::Workflow
rescuesStandardError
makes catching exceptions in tests hard.Take this spec as an example:
The result is:
Yes, I can see in the logs that an exception is logged, but I feel like in tests raising exceptions should be the rule. Any number of things can break downstream within a workflow, and sometimes (when not directly testing the unit that is the workflow) it's useful to call a thing, and not have to make an assertion that it didn't log an exception -- if that makes sense. Rescuing
StandardError
is heavy handed in the tests, because allowing those to raise is way more useful in identifying any issues.To address this I've wrapped the base class with my own, so I can re-raise the exception in a way that Temporal doesn't try to handle. I'm wondering if
Temporal::Testing
should take this into consideration and not rescue any exceptions when executing the workflow locally in tests.And the more useful result now includes the exception and stops the execution of the spec, which is what would be most helpful.
It's still not the best solution though because it now has two rescues and pollutes the stack trace.
The text was updated successfully, but these errors were encountered: