(t *testing.T)
| 78 | } |
| 79 | |
| 80 | func 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 | } |
nothing calls this directly
no test coverage detected