Files
httprunner/runner_test.go
2021-11-11 16:23:30 +08:00

40 lines
992 B
Go

package hrp
import (
"testing"
)
func TestHttpRunner(t *testing.T) {
testcase1 := &TestCase{
Config: TConfig{
Name: "TestCase1",
BaseURL: "http://httpbin.org",
},
TestSteps: []IStep{
Step("headers").
GET("/headers").
Validate().
AssertEqual("status_code", 200, "check status code").
AssertEqual("headers.\"Content-Type\"", "application/json", "check http response Content-Type"),
Step("user-agent").
GET("/user-agent").
Validate().
AssertEqual("status_code", 200, "check status code").
AssertEqual("headers.\"Content-Type\"", "application/json", "check http response Content-Type"),
Step("TestCase3").CallRefCase(&TestCase{Config: TConfig{Name: "TestCase3"}}),
},
}
testcase2 := &TestCase{
Config: TConfig{
Name: "TestCase2",
Weight: 3,
},
}
testcase3 := &TestCasePath{demoTestCaseJSONPath}
err := NewRunner(t).Run(testcase1, testcase2, testcase3)
if err != nil {
t.Fatalf("run testcase error: %v", err)
}
}