mirror of
https://github.com/httprunner/httprunner.git
synced 2026-08-28 11:36:56 +08:00
refactor: replace hardcoded log messages with constants for improved readability and maintainability
This commit is contained in:
@@ -1 +1 @@
|
|||||||
v5.0.0-beta-2506191040
|
v5.0.0-beta-2506191048
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ func (g *HTMLReportGenerator) getStepLogs(stepName string, startTime int64, elap
|
|||||||
// Simple approach: use step start/end markers for precise boundaries
|
// Simple approach: use step start/end markers for precise boundaries
|
||||||
for _, logEntry := range g.LogData {
|
for _, logEntry := range g.LogData {
|
||||||
// Check for step boundaries to control inclusion
|
// Check for step boundaries to control inclusion
|
||||||
if logEntry.Message == "run step start" {
|
if logEntry.Message == RUN_STEP_START {
|
||||||
if stepFieldValue, exists := logEntry.Fields["step"]; exists {
|
if stepFieldValue, exists := logEntry.Fields["step"]; exists {
|
||||||
if stepFieldValue == stepName {
|
if stepFieldValue == stepName {
|
||||||
inCurrentStep = true
|
inCurrentStep = true
|
||||||
@@ -198,7 +198,7 @@ func (g *HTMLReportGenerator) getStepLogs(stepName string, startTime int64, elap
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if logEntry.Message == "run step end" {
|
if logEntry.Message == RUN_STEP_END {
|
||||||
if stepFieldValue, exists := logEntry.Fields["step"]; exists {
|
if stepFieldValue, exists := logEntry.Fields["step"]; exists {
|
||||||
if stepFieldValue == stepName {
|
if stepFieldValue == stepName {
|
||||||
stepLogs = append(stepLogs, logEntry)
|
stepLogs = append(stepLogs, logEntry)
|
||||||
|
|||||||
@@ -729,6 +729,11 @@ func (r *SessionRunner) Start(givenVars map[string]interface{}) (summary *TestCa
|
|||||||
return summary, nil
|
return summary, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
RUN_STEP_START = "run step start"
|
||||||
|
RUN_STEP_END = "run step end"
|
||||||
|
)
|
||||||
|
|
||||||
func (r *SessionRunner) RunStep(step IStep) (stepResult *StepResult, err error) {
|
func (r *SessionRunner) RunStep(step IStep) (stepResult *StepResult, err error) {
|
||||||
// check for interrupt signal before running step
|
// check for interrupt signal before running step
|
||||||
select {
|
select {
|
||||||
@@ -748,7 +753,7 @@ func (r *SessionRunner) RunStep(step IStep) (stepResult *StepResult, err error)
|
|||||||
|
|
||||||
stepName := step.Name()
|
stepName := step.Name()
|
||||||
stepType := string(step.Type())
|
stepType := string(step.Type())
|
||||||
log.Info().Str("step", stepName).Str("type", stepType).Msg("run step start")
|
log.Info().Str("step", stepName).Str("type", stepType).Msg(RUN_STEP_START)
|
||||||
|
|
||||||
// run times of step
|
// run times of step
|
||||||
loopTimes := step.Config().Loops
|
loopTimes := step.Config().Loops
|
||||||
@@ -785,7 +790,7 @@ func (r *SessionRunner) RunStep(step IStep) (stepResult *StepResult, err error)
|
|||||||
Bool("success", true).
|
Bool("success", true).
|
||||||
Int64("elapsed(ms)", stepResult.Elapsed).
|
Int64("elapsed(ms)", stepResult.Elapsed).
|
||||||
Interface("exportVars", stepResult.ExportVars).
|
Interface("exportVars", stepResult.ExportVars).
|
||||||
Msg("run step end")
|
Msg(RUN_STEP_END)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// run step failed
|
// run step failed
|
||||||
@@ -793,7 +798,7 @@ func (r *SessionRunner) RunStep(step IStep) (stepResult *StepResult, err error)
|
|||||||
Str("type", stepType).
|
Str("type", stepType).
|
||||||
Bool("success", false).
|
Bool("success", false).
|
||||||
Int64("elapsed(ms)", stepResult.Elapsed).
|
Int64("elapsed(ms)", stepResult.Elapsed).
|
||||||
Msg("run step end")
|
Msg(RUN_STEP_END)
|
||||||
return stepResult, err
|
return stepResult, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user