mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-07 05:42:46 +08:00
66 lines
1.3 KiB
Go
66 lines
1.3 KiB
Go
package hrp
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestGenHTMLReport(t *testing.T) {
|
|
summary := NewSummary()
|
|
|
|
caseSummary1 := NewCaseSummary()
|
|
stepResult1 := &StepResult{}
|
|
caseSummary1.AddStepResult(stepResult1)
|
|
summary.AddCaseSummary(caseSummary1)
|
|
|
|
caseSummary2 := NewCaseSummary()
|
|
stepResult2 := &StepResult{
|
|
Name: "Test",
|
|
StepType: StepTypeRequest,
|
|
Success: false,
|
|
ContentSize: 0,
|
|
Attachments: "err",
|
|
}
|
|
caseSummary2.AddStepResult(stepResult2)
|
|
summary.AddCaseSummary(caseSummary2)
|
|
|
|
_, err := summary.GenSummary()
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
|
|
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()
|
|
}
|
|
}
|