mirror of
https://github.com/httprunner/httprunner.git
synced 2026-08-22 00:32:11 +08:00
fix: failed to generate API test report when data is null.
This commit is contained in:
@@ -235,6 +235,7 @@
|
|||||||
<a class="close" href="#record_{{$suite_index}}_{{$loop_index}}">×</a>
|
<a class="close" href="#record_{{$suite_index}}_{{$loop_index}}">×</a>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<h3>Name: {{ .Name }}</h3>
|
<h3>Name: {{ .Name }}</h3>
|
||||||
|
{{- if .Data}}
|
||||||
<h3>Request:</h3>
|
<h3>Request:</h3>
|
||||||
<div style="overflow: auto">
|
<div style="overflow: auto">
|
||||||
<table>
|
<table>
|
||||||
@@ -332,8 +333,8 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
{{- end }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
33
runner.go
33
runner.go
@@ -225,23 +225,25 @@ func (r *caseRunner) run() error {
|
|||||||
|
|
||||||
r.startTime = time.Now()
|
r.startTime = time.Now()
|
||||||
for index := range r.TestCase.TestSteps {
|
for index := range r.TestCase.TestSteps {
|
||||||
stepData, err := r.runStep(index, config)
|
stepDataObj, err := r.runStep(index, config)
|
||||||
if err != nil {
|
if stepDataObj == nil {
|
||||||
if r.hrpRunner.failfast {
|
stepDataObj = &stepData{
|
||||||
return errors.Wrap(err, "abort running due to failfast setting")
|
Name: r.TestCase.TestSteps[index].Name(),
|
||||||
|
Success: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if stepData != nil {
|
r.summary.Records = append(r.summary.Records, stepDataObj)
|
||||||
if err != nil {
|
r.summary.Success = r.summary.Success && stepDataObj.Success
|
||||||
stepData.Attachment = err.Error()
|
r.summary.Stat.Total += 1
|
||||||
}
|
if stepDataObj.Success {
|
||||||
r.summary.Records = append(r.summary.Records, stepData)
|
r.summary.Stat.Successes += 1
|
||||||
r.summary.Success = r.summary.Success && stepData.Success
|
} else {
|
||||||
r.summary.Stat.Total += 1
|
r.summary.Stat.Failures += 1
|
||||||
if stepData.Success {
|
}
|
||||||
r.summary.Stat.Successes += 1
|
if err != nil {
|
||||||
} else {
|
stepDataObj.Attachment = err.Error()
|
||||||
r.summary.Stat.Failures += 1
|
if r.hrpRunner.failfast {
|
||||||
|
return errors.Wrap(err, "abort running due to failfast setting")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -602,6 +604,7 @@ func (r *caseRunner) runStepRequest(step *TStep) (stepResult *stepData, err erro
|
|||||||
Proto: "HTTP/1.1",
|
Proto: "HTTP/1.1",
|
||||||
ProtoMajor: 1,
|
ProtoMajor: 1,
|
||||||
ProtoMinor: 1,
|
ProtoMinor: 1,
|
||||||
|
Close: true, // prevent the connection from being re-used
|
||||||
}
|
}
|
||||||
|
|
||||||
// prepare request headers
|
// prepare request headers
|
||||||
|
|||||||
@@ -123,6 +123,19 @@ func TestInitRendezvous(t *testing.T) {
|
|||||||
|
|
||||||
func TestGenHTMLReport(t *testing.T) {
|
func TestGenHTMLReport(t *testing.T) {
|
||||||
summary := newOutSummary()
|
summary := newOutSummary()
|
||||||
|
caseSummary1 := newSummary()
|
||||||
|
caseSummary2 := newSummary()
|
||||||
|
stepResult1 := &stepData{}
|
||||||
|
stepResult2 := &stepData{
|
||||||
|
Name: "Test",
|
||||||
|
StepType: stepTypeRequest,
|
||||||
|
Success: false,
|
||||||
|
ContentSize: 0,
|
||||||
|
Attachment: "err",
|
||||||
|
}
|
||||||
|
caseSummary1.Records = []*stepData{stepResult1, stepResult2, nil}
|
||||||
|
summary.appendCaseSummary(caseSummary1)
|
||||||
|
summary.appendCaseSummary(caseSummary2)
|
||||||
err := genHTMLReport(summary)
|
err := genHTMLReport(summary)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
|||||||
Reference in New Issue
Block a user