mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-19 11:59:29 +08:00
change: use NewStep to construct a new test step
This commit is contained in:
@@ -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)}"}).
|
||||
|
||||
Reference in New Issue
Block a user