@@ -75,6 +75,54 @@ type testWorkflow struct {
75
75
pendingEvents []* history.Event
76
76
}
77
77
78
+ type WorkflowTester [TResult any ] interface {
79
+ // Now returns the current time of the simulated clock in the tester.
80
+ Now () time.Time
81
+
82
+ // Execute executes the workflow under test with the given inputs.
83
+ Execute (ctx context.Context , args ... interface {})
84
+
85
+ // Registry returns the registry used by the tester.
86
+ Registry () * registry.Registry
87
+
88
+ // OnActivity registers a mock activity.
89
+ OnActivity (activity workflow.Activity , args ... interface {}) * mock.Call
90
+
91
+ // OnActivityByName registers a mock activity with the given name.
92
+ OnActivityByName (name string , activity workflow.Activity , args ... interface {}) * mock.Call
93
+
94
+ // OnSubworkflow registers a mock sub-workflow.
95
+ OnSubWorkflow (workflow workflow.Workflow , args ... interface {}) * mock.Call
96
+
97
+ // OnSubWorkflowByName registers a mock sub-workflow with the given name.
98
+ OnSubWorkflowByName (name string , workflow workflow.Workflow , args ... interface {}) * mock.Call
99
+
100
+ // SignalWorkflow signals the workflow under test with the given signal name and value.
101
+ SignalWorkflow (signalName string , value interface {})
102
+
103
+ // SignalWorkflowInstance signals the given workflow instance with the given signal name and value.
104
+ SignalWorkflowInstance (wfi * core.WorkflowInstance , signalName string , value interface {}) error
105
+
106
+ // WorkflowFinished returns true if the workflow under test is finished.
107
+ WorkflowFinished () bool
108
+
109
+ // WorkflowResult returns the result of the workflow under test. If the workflow is not finished yet, this will
110
+ // error.
111
+ WorkflowResult () (TResult , error )
112
+
113
+ // AssertExpectations asserts any assertions set up for mock activities and sub-workflow
114
+ AssertExpectations (t * testing.T )
115
+
116
+ // ScheduleCallback schedules the given callback after the given delay in workflow time (not wall clock).
117
+ ScheduleCallback (delay time.Duration , callback func ())
118
+
119
+ // ListenSubWorkflow registers a listener that is called whenever a sub-workflow is started. The listener is called
120
+ // with the workflow instance of the sub-workflow and the name of the sub-workflow.
121
+ ListenSubWorkflow (listener func (instance * core.WorkflowInstance , name string ))
122
+ }
123
+
124
+ var _ WorkflowTester [any ] = (* workflowTester [any ])(nil )
125
+
78
126
type workflowTester [TResult any ] struct {
79
127
options * options
80
128
0 commit comments