mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-25 17:44:02 +08:00
fix: failed to record the step of occuring error in the html report
This commit is contained in:
@@ -300,6 +300,16 @@ func runStepRequest(r *SessionRunner, step *TStep) (stepResult *StepResult, err
|
||||
if err != nil {
|
||||
stepResult.Attachment = err.Error()
|
||||
}
|
||||
// update summary
|
||||
r.summary.Records = append(r.summary.Records, stepResult)
|
||||
r.summary.Stat.Total += 1
|
||||
if stepResult.Success {
|
||||
r.summary.Stat.Successes += 1
|
||||
} else {
|
||||
r.summary.Stat.Failures += 1
|
||||
// update summary result to failed
|
||||
r.summary.Success = false
|
||||
}
|
||||
}()
|
||||
|
||||
// override step variables
|
||||
@@ -442,17 +452,6 @@ func runStepRequest(r *SessionRunner, step *TStep) (stepResult *StepResult, err
|
||||
stepResult.ContentSize = resp.ContentLength
|
||||
stepResult.Data = sessionData
|
||||
|
||||
// update summary
|
||||
r.summary.Records = append(r.summary.Records, stepResult)
|
||||
r.summary.Stat.Total += 1
|
||||
if stepResult.Success {
|
||||
r.summary.Stat.Successes += 1
|
||||
} else {
|
||||
r.summary.Stat.Failures += 1
|
||||
// update summary result to failed
|
||||
r.summary.Success = false
|
||||
}
|
||||
|
||||
return stepResult, err
|
||||
}
|
||||
|
||||
|
||||
@@ -44,13 +44,20 @@ func (s *StepTestCaseWithOptionalArgs) Struct() *TStep {
|
||||
return s.step
|
||||
}
|
||||
|
||||
func (s *StepTestCaseWithOptionalArgs) Run(r *SessionRunner) (*StepResult, error) {
|
||||
stepResult := &StepResult{
|
||||
func (s *StepTestCaseWithOptionalArgs) Run(r *SessionRunner) (stepResult *StepResult, err error) {
|
||||
stepResult = &StepResult{
|
||||
Name: s.step.Name,
|
||||
StepType: stepTypeTestCase,
|
||||
Success: false,
|
||||
}
|
||||
|
||||
defer func() {
|
||||
// update testcase summary
|
||||
if err != nil {
|
||||
stepResult.Attachment = err.Error()
|
||||
}
|
||||
}()
|
||||
|
||||
stepVariables, err := r.MergeStepVariables(s.step.Variables)
|
||||
if err != nil {
|
||||
return stepResult, err
|
||||
@@ -82,12 +89,10 @@ func (s *StepTestCaseWithOptionalArgs) Run(r *SessionRunner) (*StepResult, error
|
||||
start := time.Now()
|
||||
// run referenced testcase with step variables
|
||||
err = sessionRunner.Start(stepVariables)
|
||||
stepResult.Elapsed = time.Since(start).Milliseconds()
|
||||
if err != nil {
|
||||
stepResult.Attachment = err.Error()
|
||||
r.summary.Success = false
|
||||
return stepResult, err
|
||||
if err == nil {
|
||||
stepResult.Success = true
|
||||
}
|
||||
stepResult.Elapsed = time.Since(start).Milliseconds()
|
||||
summary := sessionRunner.GetSummary()
|
||||
// update step names
|
||||
for _, record := range summary.Records {
|
||||
@@ -96,7 +101,6 @@ func (s *StepTestCaseWithOptionalArgs) Run(r *SessionRunner) (*StepResult, error
|
||||
stepResult.Data = summary.Records
|
||||
// export testcase export variables
|
||||
stepResult.ExportVars = summary.InOut.ExportVars
|
||||
stepResult.Success = true
|
||||
|
||||
// merge testcase summary
|
||||
r.summary.Records = append(r.summary.Records, summary.Records...)
|
||||
@@ -104,5 +108,5 @@ func (s *StepTestCaseWithOptionalArgs) Run(r *SessionRunner) (*StepResult, error
|
||||
r.summary.Stat.Successes += summary.Stat.Successes
|
||||
r.summary.Stat.Failures += summary.Stat.Failures
|
||||
|
||||
return stepResult, nil
|
||||
return stepResult, err
|
||||
}
|
||||
|
||||
@@ -239,6 +239,16 @@ func runStepWebSocket(r *SessionRunner, step *TStep) (stepResult *StepResult, er
|
||||
if err != nil {
|
||||
stepResult.Attachment = err.Error()
|
||||
}
|
||||
// update summary
|
||||
r.summary.Records = append(r.summary.Records, stepResult)
|
||||
r.summary.Stat.Total += 1
|
||||
if stepResult.Success {
|
||||
r.summary.Stat.Successes += 1
|
||||
} else {
|
||||
r.summary.Stat.Failures += 1
|
||||
// update summary result to failed
|
||||
r.summary.Success = false
|
||||
}
|
||||
}()
|
||||
|
||||
// override step variables
|
||||
@@ -385,16 +395,6 @@ func runStepWebSocket(r *SessionRunner, step *TStep) (stepResult *StepResult, er
|
||||
stepResult.Success = true
|
||||
}
|
||||
|
||||
// update summary
|
||||
r.summary.Records = append(r.summary.Records, stepResult)
|
||||
r.summary.Stat.Total += 1
|
||||
if stepResult.Success {
|
||||
r.summary.Stat.Successes += 1
|
||||
} else {
|
||||
r.summary.Stat.Failures += 1
|
||||
// update summary result to failed
|
||||
r.summary.Success = false
|
||||
}
|
||||
return stepResult, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -199,5 +199,6 @@ func newSummary() *TestCaseSummary {
|
||||
Stat: &TestStepStat{},
|
||||
Time: &TestCaseTime{},
|
||||
InOut: &TestCaseInOut{},
|
||||
Records: []*StepResult{},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user