refactor: log step start time and elapsed(ms)

This commit is contained in:
lilong.129
2024-11-10 10:40:44 +08:00
parent 52b45a55d2
commit 96a744365b
8 changed files with 97 additions and 83 deletions
+11 -7
View File
@@ -3,6 +3,7 @@ package hrp
import (
"fmt"
"strings"
"time"
"github.com/pkg/errors"
"github.com/rs/zerolog/log"
@@ -654,6 +655,13 @@ func runStepMobileUI(s *SessionRunner, step IStep) (stepResult *StepResult, err
"osType": mobileStep.OSType,
})
// init wda/uia/hdc driver
caseConfig := s.caseRunner.TestCase.Config.Get()
uiDriver, err := initUIClient(mobileStep.Serial, mobileStep.OSType, caseConfig)
if err != nil {
return
}
identifier := mobileStep.Identifier
if mobileStep.Options != nil && identifier == "" {
identifier = mobileStep.Options.Identifier
@@ -667,19 +675,14 @@ func runStepMobileUI(s *SessionRunner, step IStep) (stepResult *StepResult, err
}
}
start := time.Now()
stepResult = &StepResult{
Name: step.Name(),
Identifier: identifier,
StepType: step.Type(),
Success: false,
ContentSize: 0,
}
// init wda/uia/hdc driver
caseConfig := s.caseRunner.TestCase.Config.Get()
uiDriver, err := initUIClient(mobileStep.Serial, mobileStep.OSType, caseConfig)
if err != nil {
return
StartTime: start.Unix(),
}
defer func() {
@@ -708,6 +711,7 @@ func runStepMobileUI(s *SessionRunner, step IStep) (stepResult *StepResult, err
attachments[key] = value
}
stepResult.Attachments = attachments
stepResult.Elapsed = time.Since(start).Milliseconds()
}()
// prepare actions