feat: support setting global testcase timeout and step timeout

This commit is contained in:
debugtalk
2022-06-26 11:30:56 +08:00
parent 54799cdc3a
commit 752e59186f
5 changed files with 101 additions and 10 deletions
+8
View File
@@ -2,6 +2,7 @@ package hrp
import (
"reflect"
"time"
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
)
@@ -28,6 +29,7 @@ type TConfig struct {
ParametersSetting *TParamsConfig `json:"parameters_setting,omitempty" yaml:"parameters_setting,omitempty"`
ThinkTimeSetting *ThinkTimeConfig `json:"think_time,omitempty" yaml:"think_time,omitempty"`
WebSocketSetting *WebSocketConfig `json:"websocket,omitempty" yaml:"websocket,omitempty"`
Timeout float64 `json:"timeout,omitempty" yaml:"timeout,omitempty"` // global timeout in seconds
Export []string `json:"export,omitempty" yaml:"export,omitempty"`
Weight int `json:"weight,omitempty" yaml:"weight,omitempty"`
Path string `json:"path,omitempty" yaml:"path,omitempty"` // testcase file path
@@ -69,6 +71,12 @@ func (c *TConfig) SetThinkTime(strategy thinkTimeStrategy, cfg interface{}, limi
return c
}
// SetTimeout sets testcase timeout in seconds.
func (c *TConfig) SetTimeout(timeout time.Duration) *TConfig {
c.Timeout = timeout.Seconds()
return c
}
// ExportVars specifies variable names to export for current testcase.
func (c *TConfig) ExportVars(vars ...string) *TConfig {
c.Export = vars