change: use NewStep to construct a new test step

This commit is contained in:
debugtalk
2021-12-07 11:11:03 +08:00
parent 5de87ac875
commit b8573c2ea9
11 changed files with 47 additions and 42 deletions

View File

@@ -19,7 +19,7 @@ func TestCaseConfigVariables(t *testing.T) {
Verify: false,
},
TestSteps: []hrp.IStep{
hrp.Step("get with params").
hrp.NewStep("get with params").
GET("/get").
WithParams(map[string]interface{}{"foo1": "$var1", "foo2": "bar2"}).
WithHeaders(map[string]string{"User-Agent": "$agent"}).
@@ -47,7 +47,7 @@ func TestCaseStepVariables(t *testing.T) {
Verify: false,
},
TestSteps: []hrp.IStep{
hrp.Step("get with params").
hrp.NewStep("get with params").
WithVariables(map[string]interface{}{
"var1": "bar1",
"agent": "HttpRunnerPlus",
@@ -85,7 +85,7 @@ func TestCaseOverrideConfigVariables(t *testing.T) {
Verify: false,
},
TestSteps: []hrp.IStep{
hrp.Step("get with params").
hrp.NewStep("get with params").
WithVariables(map[string]interface{}{
"var1": "bar1", // override config variable
"agent": "$agent", // reference config variable
@@ -125,7 +125,7 @@ func TestCaseParseVariables(t *testing.T) {
},
},
TestSteps: []hrp.IStep{
hrp.Step("get with params").
hrp.NewStep("get with params").
WithVariables(map[string]interface{}{
"n": 3,
"b": 34.5,
@@ -140,7 +140,7 @@ func TestCaseParseVariables(t *testing.T) {
AssertEqual("status_code", 200, "check status code").
AssertLengthEqual("body.args.foo1", 5, "check args foo1").
AssertEqual("body.args.foo2", "34.5", "check args foo2"), // notice: request params value will be converted to string
hrp.Step("post json data with functions").
hrp.NewStep("post json data with functions").
POST("/post").
WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus"}).
WithBody(map[string]interface{}{"foo1": "${gen_random_string($n)}", "foo2": "${max($a, $b)}"}).