mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-08 17:29:34 +08:00
feat: support pre hook and post hook for actions
This commit is contained in:
@@ -23,6 +23,7 @@ type ActionOptions struct {
|
||||
Frequency int `json:"frequency,omitempty" yaml:"frequency,omitempty"`
|
||||
|
||||
ScreenOptions
|
||||
HookOptions
|
||||
|
||||
// set custiom options such as textview, id, description
|
||||
Custom map[string]interface{} `json:"custom,omitempty" yaml:"custom,omitempty"`
|
||||
|
||||
31
uixt/option/hook.go
Normal file
31
uixt/option/hook.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package option
|
||||
|
||||
// HookOptions contains options for action hooks
|
||||
type HookOptions struct {
|
||||
// pre hook before action
|
||||
PreHook func()
|
||||
// post hook after action
|
||||
PostHook func()
|
||||
}
|
||||
|
||||
// WithPreHook sets the pre hook before action
|
||||
func WithPreHook(preHook func()) ActionOption {
|
||||
return func(o *ActionOptions) {
|
||||
o.PreHook = preHook
|
||||
}
|
||||
}
|
||||
|
||||
// WithPostHook sets the post hook after action
|
||||
func WithPostHook(postHook func()) ActionOption {
|
||||
return func(o *ActionOptions) {
|
||||
o.PostHook = postHook
|
||||
}
|
||||
}
|
||||
|
||||
// WithHooks sets the pre hook and post hook
|
||||
func WithHooks(preHook func(), postHook func()) ActionOption {
|
||||
return func(o *ActionOptions) {
|
||||
o.PreHook = preHook
|
||||
o.PostHook = postHook
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user