mirror of
https://github.com/httprunner/httprunner.git
synced 2026-08-28 19:47:14 +08:00
feat: NewSummary, NewCaseSummary
This commit is contained in:
+44
-8
@@ -1,12 +1,20 @@
|
||||
package hrp
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestGenHTMLReport(t *testing.T) {
|
||||
summary := newOutSummary()
|
||||
caseSummary1 := newSummary()
|
||||
caseSummary2 := newSummary()
|
||||
summary := NewSummary()
|
||||
|
||||
caseSummary1 := NewCaseSummary()
|
||||
stepResult1 := &StepResult{}
|
||||
caseSummary1.AddStepResult(stepResult1)
|
||||
summary.AddCaseSummary(caseSummary1)
|
||||
|
||||
caseSummary2 := NewCaseSummary()
|
||||
stepResult2 := &StepResult{
|
||||
Name: "Test",
|
||||
StepType: stepTypeRequest,
|
||||
@@ -14,11 +22,39 @@ func TestGenHTMLReport(t *testing.T) {
|
||||
ContentSize: 0,
|
||||
Attachments: "err",
|
||||
}
|
||||
caseSummary1.Records = []*StepResult{stepResult1, stepResult2, nil}
|
||||
summary.appendCaseSummary(caseSummary1)
|
||||
summary.appendCaseSummary(caseSummary2)
|
||||
err := summary.genHTMLReport()
|
||||
caseSummary2.AddStepResult(stepResult2)
|
||||
summary.AddCaseSummary(caseSummary2)
|
||||
|
||||
err := summary.GenHTMLReport()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTestCaseSummary_AddStepResult(t *testing.T) {
|
||||
caseSummary := NewCaseSummary()
|
||||
stepResult1 := &StepResult{
|
||||
Name: "Test1",
|
||||
StepType: stepTypeRequest,
|
||||
Success: true,
|
||||
ContentSize: 0,
|
||||
Attachments: "err",
|
||||
}
|
||||
caseSummary.AddStepResult(stepResult1)
|
||||
stepResult2 := &StepResult{
|
||||
Name: "Test2",
|
||||
StepType: stepTypeTestCase,
|
||||
Success: false,
|
||||
ContentSize: 0,
|
||||
Attachments: "err",
|
||||
Data: []*StepResult{stepResult1},
|
||||
}
|
||||
caseSummary.AddStepResult(stepResult2)
|
||||
|
||||
if !assert.Equal(t, 2, len(caseSummary.Records)) {
|
||||
t.Fatal()
|
||||
}
|
||||
if !assert.False(t, caseSummary.Success) {
|
||||
t.Fatal()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user