mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-16 20:27:37 +08:00
feat: support think time for load testing #120
This commit is contained in:
33
step.go
33
step.go
@@ -40,6 +40,12 @@ func (c *TConfig) WithParameters(parameters map[string]interface{}) *TConfig {
|
||||
return c
|
||||
}
|
||||
|
||||
// SetThinkTime sets think time config for current testcase.
|
||||
func (c *TConfig) SetThinkTime(strategy string, cfg interface{}, limit float64) *TConfig {
|
||||
c.ThinkTime = &ThinkTimeConfig{strategy, cfg, limit}
|
||||
return c
|
||||
}
|
||||
|
||||
// ExportVars specifies variable names to export for current testcase.
|
||||
func (c *TConfig) ExportVars(vars ...string) *TConfig {
|
||||
c.Export = vars
|
||||
@@ -193,6 +199,16 @@ func (s *StepRequest) EndTransaction(name string) *StepTransaction {
|
||||
}
|
||||
}
|
||||
|
||||
// SetThinkTime sets think time.
|
||||
func (s *StepRequest) SetThinkTime(time float64) *StepThinkTime {
|
||||
s.step.ThinkTime = &ThinkTime{
|
||||
Time: time,
|
||||
}
|
||||
return &StepThinkTime{
|
||||
step: s.step,
|
||||
}
|
||||
}
|
||||
|
||||
// StepRequestWithOptionalArgs implements IStep interface.
|
||||
type StepRequestWithOptionalArgs struct {
|
||||
step *TStep
|
||||
@@ -355,6 +371,23 @@ func (s *StepTestCaseWithOptionalArgs) ToStruct() *TStep {
|
||||
return s.step
|
||||
}
|
||||
|
||||
// StepThinkTime implements IStep interface.
|
||||
type StepThinkTime struct {
|
||||
step *TStep
|
||||
}
|
||||
|
||||
func (s *StepThinkTime) Name() string {
|
||||
return s.step.Name
|
||||
}
|
||||
|
||||
func (s *StepThinkTime) Type() string {
|
||||
return "thinktime"
|
||||
}
|
||||
|
||||
func (s *StepThinkTime) ToStruct() *TStep {
|
||||
return s.step
|
||||
}
|
||||
|
||||
// StepTransaction implements IStep interface.
|
||||
type StepTransaction struct {
|
||||
step *TStep
|
||||
|
||||
Reference in New Issue
Block a user