mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-04 23:16:57 +08:00
change: add logs for loop index
This commit is contained in:
+17
-14
@@ -35,7 +35,7 @@ var (
|
||||
|
||||
type MobileStep struct {
|
||||
Serial string `json:"serial,omitempty" yaml:"serial,omitempty"`
|
||||
Times int `json:"times,omitempty" yaml:"times,omitempty"`
|
||||
Loops int `json:"loops,omitempty" yaml:"loops,omitempty"`
|
||||
uixt.MobileAction `yaml:",inline"`
|
||||
Actions []uixt.MobileAction `json:"actions,omitempty" yaml:"actions,omitempty"`
|
||||
}
|
||||
@@ -303,9 +303,9 @@ func (s *StepMobile) Input(text string, options ...uixt.ActionOption) *StepMobil
|
||||
return &StepMobile{step: s.step}
|
||||
}
|
||||
|
||||
// LoopTimes specify running times for the current step
|
||||
func (s *StepMobile) LoopTimes(n int) *StepMobile {
|
||||
s.mobileStep().Times = n
|
||||
// Loop specify running times for the current step
|
||||
func (s *StepMobile) Loop(times int) *StepMobile {
|
||||
s.mobileStep().Loops = times
|
||||
return &StepMobile{step: s.step}
|
||||
}
|
||||
|
||||
@@ -608,19 +608,22 @@ func runStepMobileUI(s *SessionRunner, step *TStep) (stepResult *StepResult, err
|
||||
actions = mobileStep.Actions
|
||||
}
|
||||
|
||||
// run times
|
||||
times := mobileStep.Times
|
||||
if times < 0 {
|
||||
log.Warn().Int("times", times).Msg("times should be positive, set to 1")
|
||||
times = 1
|
||||
} else if times == 0 {
|
||||
times = 1
|
||||
} else if times > 1 {
|
||||
log.Info().Int("times", times).Msg("run actions with specified times")
|
||||
// run times of actions
|
||||
loopTimes := mobileStep.Loops
|
||||
if loopTimes < 0 {
|
||||
log.Warn().Int("loopTimes", loopTimes).Msg("times should be positive, set to 1")
|
||||
loopTimes = 1
|
||||
} else if loopTimes == 0 {
|
||||
loopTimes = 1
|
||||
} else if loopTimes > 1 {
|
||||
log.Info().Int("loopTimes", loopTimes).Msg("run actions with specified loop times")
|
||||
}
|
||||
|
||||
// run actions with specified times
|
||||
for i := 0; i < times; i++ {
|
||||
for i := 0; i < loopTimes; i++ {
|
||||
if i > 0 {
|
||||
log.Info().Int("index", i+1).Msg("start running actions in loop")
|
||||
}
|
||||
for _, action := range actions {
|
||||
if action.Params, err = s.caseRunner.parser.Parse(action.Params, stepVariables); err != nil {
|
||||
if !code.IsErrorPredefined(err) {
|
||||
|
||||
Reference in New Issue
Block a user