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
I think that testing that an Activity or a Workflow is Called once is a common use case. I also think that it is a common use case that Activities and Workflows are not named the same (see Additional comments section below).
Users of this function might incorrectly see their tests passing when they should not.
Possible fix
My understanding is that the behavior was introduced by that PR, which makes the assertion check if the number of Activities OR the number of Workflows were called N times. Here as we have 0 workflows named MyActivity, they were never called. Hence the assertion env.AssertNumberOfCalls(t, "MyActivity", 0) succeeds.
Here is an idea to fix that. This is only an attempt - I’m not familiar with the repo:
Revert that PR -> the bug will be fixed. It will assert that nbWorkflows + nbActivities == N
In order to take into account that issue -> create two methods:
func (e *TestWorkflowEnvironment) AssertNumberOfCallsActivity(t mock.TestingT, methodName string, expectedCalls int) bool
func (e *TestWorkflowEnvironment) AssertNumberOfCallsWorkflow(t mock.TestingT, methodName string, expectedCalls int) bool
If you agree on the principle, I can open a PR.
The text was updated successfully, but these errors were encountered:
Yes I think they would fit well for my second bullet point, thank you.
I still believe that env.AssertNumberOfCalls behavior could introduce errors in user tests. According to the method naming, if someone asserts that an Activity was called once, then they would expect the test to fail if the Activity was never called, and it doesn't.
AssertNumberOfCalls is inherently ambiguous since it doesn't differentiate between workflow, activity or nexus calls. If you are trying to assert on the number of activity calls you should use AssertActivityNumberOfCalls .
Expected Behavior
I expect
AssertNumberOfCalls
to succeed only with one given “expectedCalls” value.In the “Steps to reproduce” section below, there are two assertions to assert the number of times the Activity is Called: 0 and 1. I expect that:
Actual Behavior
It is possible for
AssertNumberOfCalls
to succeed with two “expectedCalls” values.In the “Steps to reproduce” section below, the two assertions succeed and the test succeeds.
Steps to Reproduce the Problem
main.go:
main_test.go:
Specifications
go.mod
Additional comments
Impact
I think that testing that an Activity or a Workflow is Called once is a common use case. I also think that it is a common use case that Activities and Workflows are not named the same (see Additional comments section below).
Users of this function might incorrectly see their tests passing when they should not.
Possible fix
My understanding is that the behavior was introduced by that PR, which makes the assertion check if the number of Activities OR the number of Workflows were called N times. Here as we have 0 workflows named MyActivity, they were never called. Hence the assertion
env.AssertNumberOfCalls(t, "MyActivity", 0)
succeeds.Here is an idea to fix that. This is only an attempt - I’m not familiar with the repo:
If you agree on the principle, I can open a PR.
The text was updated successfully, but these errors were encountered: