mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-08 17:29:34 +08:00
feat: add mobile ui actions to summary
This commit is contained in:
@@ -1 +1 @@
|
||||
v5.0.0+2411112155
|
||||
v5.0.0+2411112311
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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(),
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user