MCPcopy Create free account
hub / github.com/httprunner/httprunner / TestRunRequestStatOn

Function TestRunRequestStatOn

hrp/step_request_test.go:80–159  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

78}
79
80func TestRunRequestStatOn(t *testing.T) {
81 testcase := &TestCase{
82 Config: NewConfig("test").SetBaseURL("https://postman-echo.com"),
83 TestSteps: []IStep{stepGET, stepPOSTData},
84 }
85 caseRunner, _ := NewRunner(t).SetHTTPStatOn().NewCaseRunner(testcase)
86 sessionRunner := caseRunner.NewSession()
87 if err := sessionRunner.Start(nil); err != nil {
88 t.Fatal()
89 }
90 summary, _ := sessionRunner.GetSummary()
91
92 stat := summary.Records[0].HttpStat
93 if !assert.GreaterOrEqual(t, stat["DNSLookup"], int64(0)) {
94 t.Fatal()
95 }
96 if !assert.Greater(t, stat["TCPConnection"], int64(0)) {
97 t.Fatal()
98 }
99 if !assert.Greater(t, stat["TLSHandshake"], int64(0)) {
100 t.Fatal()
101 }
102 if !assert.Greater(t, stat["ServerProcessing"], int64(0)) {
103 t.Fatal()
104 }
105 if !assert.GreaterOrEqual(t, stat["ContentTransfer"], int64(0)) {
106 t.Fatal()
107 }
108 if !assert.GreaterOrEqual(t, stat["NameLookup"], int64(0)) {
109 t.Fatal()
110 }
111 if !assert.Greater(t, stat["Connect"], int64(0)) {
112 t.Fatal()
113 }
114 if !assert.Greater(t, stat["Pretransfer"], int64(0)) {
115 t.Fatal()
116 }
117 if !assert.Greater(t, stat["StartTransfer"], int64(0)) {
118 t.Fatal()
119 }
120 if !assert.Greater(t, stat["Total"], int64(5)) {
121 t.Fatal()
122 }
123 if !assert.Less(t, stat["Total"]-summary.Records[0].Elapsed, int64(3)) {
124 t.Fatal()
125 }
126
127 // reuse connection
128 stat = summary.Records[1].HttpStat
129 if !assert.Equal(t, int64(0), stat["DNSLookup"]) {
130 t.Fatal()
131 }
132 if !assert.Equal(t, int64(0), stat["TCPConnection"]) {
133 t.Fatal()
134 }
135 if !assert.Equal(t, int64(0), stat["TLSHandshake"]) {
136 t.Fatal()
137 }

Callers

nothing calls this directly

Calls 8

NewSessionMethod · 0.95
NewConfigFunction · 0.85
NewRunnerFunction · 0.85
SetBaseURLMethod · 0.80
NewCaseRunnerMethod · 0.80
SetHTTPStatOnMethod · 0.80
GetSummaryMethod · 0.80
StartMethod · 0.65

Tested by

no test coverage detected