diff --git a/examples/postman_echo/hardcode_test.go b/examples/postman_echo/hardcode_test.go new file mode 100644 index 00000000..6e8340b8 --- /dev/null +++ b/examples/postman_echo/hardcode_test.go @@ -0,0 +1,36 @@ +package postman_echo + +import ( + "testing" + + "github.com/httprunner/httpboomer" +) + +func TestCaseHardcode(t *testing.T) { + testcase := &httpboomer.TestCase{ + Config: httpboomer.TConfig{ + Name: "request methods testcase in hardcode", + BaseURL: "https://postman-echo.com", + Verify: false, + }, + TestSteps: []httpboomer.IStep{ + httpboomer.Step("get with params"). + GET("/get"). + WithParams(map[string]interface{}{"foo1": "bar1", "foo2": "bar2"}). + WithHeaders(map[string]string{"User-Agent": "HttpBoomer"}). + Validate(). + AssertEqual("status_code", 200, "check status code"), + httpboomer.Step("post raw text"). + POST("/post"). + WithHeaders(map[string]string{"User-Agent": "HttpBoomer", "Content-Type": "text/plain"}). + WithData("This is expected to be sent back as part of response body."). + Validate(). + AssertEqual("status_code", 200, "check status code"), + }, + } + + err := httpboomer.Test(testcase) + if err != nil { + t.Fatalf("run testcase error: %v", err) + } +} diff --git a/runner.go b/runner.go index 6a21ca34..4419619a 100644 --- a/runner.go +++ b/runner.go @@ -58,6 +58,7 @@ func (r *Runner) runStep(step *TStep) error { var v []interface{} v = append(v, req.Header(step.Request.Headers)) v = append(v, req.Param(step.Request.Params)) + v = append(v, step.Request.Data) for cookieName, cookieValue := range step.Request.Cookies { v = append(v, &http.Cookie{