mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-07 00:17:37 +08:00
feat: add mobile ui actions to summary
This commit is contained in:
@@ -1 +1 @@
|
|||||||
v5.0.0+2411112155
|
v5.0.0+2411112311
|
||||||
|
|||||||
+10
-1
@@ -67,7 +67,7 @@ func (s *StepMobile) Serial(serial string) *StepMobile {
|
|||||||
return s
|
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{
|
s.obj().Actions = append(s.obj().Actions, uixt.MobileAction{
|
||||||
Method: uixt.ACTION_LOG,
|
Method: uixt.ACTION_LOG,
|
||||||
Params: actionName,
|
Params: actionName,
|
||||||
@@ -718,6 +718,15 @@ func runStepMobileUI(s *SessionRunner, step IStep) (stepResult *StepResult, err
|
|||||||
}
|
}
|
||||||
return 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)
|
err = uiDriver.DoAction(action)
|
||||||
actionResult.Elapsed = time.Since(actionStartTime).Milliseconds()
|
actionResult.Elapsed = time.Since(actionStartTime).Milliseconds()
|
||||||
stepResult.Actions = append(stepResult.Actions, actionResult)
|
stepResult.Actions = append(stepResult.Actions, actionResult)
|
||||||
|
|||||||
+18
-2
@@ -15,6 +15,7 @@ import (
|
|||||||
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
||||||
"github.com/httprunner/httprunner/v4/hrp/internal/config"
|
"github.com/httprunner/httprunner/v4/hrp/internal/config"
|
||||||
"github.com/httprunner/httprunner/v4/hrp/internal/version"
|
"github.com/httprunner/httprunner/v4/hrp/internal/version"
|
||||||
|
"github.com/httprunner/httprunner/v4/hrp/pkg/uixt"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewSummary() *Summary {
|
func NewSummary() *Summary {
|
||||||
@@ -25,7 +26,11 @@ func NewSummary() *Summary {
|
|||||||
}
|
}
|
||||||
return &Summary{
|
return &Summary{
|
||||||
Success: true,
|
Success: true,
|
||||||
Stat: &Stat{},
|
Stat: &Stat{
|
||||||
|
TestSteps: TestStepStat{
|
||||||
|
Actions: make(map[uixt.ActionMethod]int),
|
||||||
|
},
|
||||||
|
},
|
||||||
Time: &TestCaseTime{
|
Time: &TestCaseTime{
|
||||||
StartAt: config.StartTime,
|
StartAt: config.StartTime,
|
||||||
},
|
},
|
||||||
@@ -64,6 +69,14 @@ func (s *Summary) AddCaseSummary(caseSummary *TestCaseSummary) {
|
|||||||
// if multiple testcases have different root path, use current working dir
|
// if multiple testcases have different root path, use current working dir
|
||||||
s.rootDir = config.RootDir
|
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) {
|
func (s *Summary) SetupDirPath() (path string, err error) {
|
||||||
@@ -136,6 +149,7 @@ type TestStepStat struct {
|
|||||||
Total int `json:"total" yaml:"total"`
|
Total int `json:"total" yaml:"total"`
|
||||||
Successes int `json:"successes" yaml:"successes"`
|
Successes int `json:"successes" yaml:"successes"`
|
||||||
Failures int `json:"failures" yaml:"failures"`
|
Failures int `json:"failures" yaml:"failures"`
|
||||||
|
Actions map[uixt.ActionMethod]int `json:"actions" yaml:"actions"` // record action stats
|
||||||
}
|
}
|
||||||
|
|
||||||
type TestCaseTime struct {
|
type TestCaseTime struct {
|
||||||
@@ -152,7 +166,9 @@ type Platform struct {
|
|||||||
func NewCaseSummary() *TestCaseSummary {
|
func NewCaseSummary() *TestCaseSummary {
|
||||||
return &TestCaseSummary{
|
return &TestCaseSummary{
|
||||||
Success: true,
|
Success: true,
|
||||||
Stat: &TestStepStat{},
|
Stat: &TestStepStat{
|
||||||
|
Actions: make(map[uixt.ActionMethod]int),
|
||||||
|
},
|
||||||
Time: &TestCaseTime{
|
Time: &TestCaseTime{
|
||||||
StartAt: time.Now(),
|
StartAt: time.Now(),
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user