diff --git a/hrp/internal/version/VERSION b/hrp/internal/version/VERSION index 7ac0934b..d71b395b 100644 --- a/hrp/internal/version/VERSION +++ b/hrp/internal/version/VERSION @@ -1 +1 @@ -v5.0.0+2411112155 +v5.0.0+2411112311 diff --git a/hrp/step_mobile_ui.go b/hrp/step_mobile_ui.go index c40d582a..894d0752 100644 --- a/hrp/step_mobile_ui.go +++ b/hrp/step_mobile_ui.go @@ -67,7 +67,7 @@ func (s *StepMobile) Serial(serial string) *StepMobile { return s } -func (s *StepMobile) Log(actionName string) *StepMobile { +func (s *StepMobile) Log(actionName uixt.ActionMethod) *StepMobile { s.obj().Actions = append(s.obj().Actions, uixt.MobileAction{ Method: uixt.ACTION_LOG, Params: actionName, @@ -718,6 +718,15 @@ func runStepMobileUI(s *SessionRunner, step IStep) (stepResult *StepResult, err } return stepResult, err } + + // stat uixt action + if action.Method == uixt.ACTION_LOG { + log.Info().Interface("action", action.Params).Msg("stat uixt action") + actionMethod := uixt.ActionMethod(action.Params.(string)) + s.summary.Stat.Actions[actionMethod]++ + continue + } + err = uiDriver.DoAction(action) actionResult.Elapsed = time.Since(actionStartTime).Milliseconds() stepResult.Actions = append(stepResult.Actions, actionResult) diff --git a/hrp/summary.go b/hrp/summary.go index 8e921abe..c11f69a5 100644 --- a/hrp/summary.go +++ b/hrp/summary.go @@ -15,6 +15,7 @@ import ( "github.com/httprunner/httprunner/v4/hrp/internal/builtin" "github.com/httprunner/httprunner/v4/hrp/internal/config" "github.com/httprunner/httprunner/v4/hrp/internal/version" + "github.com/httprunner/httprunner/v4/hrp/pkg/uixt" ) func NewSummary() *Summary { @@ -25,7 +26,11 @@ func NewSummary() *Summary { } return &Summary{ Success: true, - Stat: &Stat{}, + Stat: &Stat{ + TestSteps: TestStepStat{ + Actions: make(map[uixt.ActionMethod]int), + }, + }, Time: &TestCaseTime{ StartAt: config.StartTime, }, @@ -64,6 +69,14 @@ func (s *Summary) AddCaseSummary(caseSummary *TestCaseSummary) { // if multiple testcases have different root path, use current working dir s.rootDir = config.RootDir } + + // merge action stats + for action, count := range caseSummary.Stat.Actions { + if _, ok := s.Stat.TestSteps.Actions[action]; !ok { + s.Stat.TestSteps.Actions[action] = 0 + } + s.Stat.TestSteps.Actions[action] += count + } } func (s *Summary) SetupDirPath() (path string, err error) { @@ -133,9 +146,10 @@ type TestCaseStat struct { } type TestStepStat struct { - Total int `json:"total" yaml:"total"` - Successes int `json:"successes" yaml:"successes"` - Failures int `json:"failures" yaml:"failures"` + Total int `json:"total" yaml:"total"` + Successes int `json:"successes" yaml:"successes"` + Failures int `json:"failures" yaml:"failures"` + Actions map[uixt.ActionMethod]int `json:"actions" yaml:"actions"` // record action stats } type TestCaseTime struct { @@ -152,7 +166,9 @@ type Platform struct { func NewCaseSummary() *TestCaseSummary { return &TestCaseSummary{ Success: true, - Stat: &TestStepStat{}, + Stat: &TestStepStat{ + Actions: make(map[uixt.ActionMethod]int), + }, Time: &TestCaseTime{ StartAt: time.Now(), },